[asterisk-scf-commits] asterisk-scf/release/media_operations_core.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Sep 14 10:56:02 CDT 2011
branch "master" has been updated
via 4456735a649c3828f7f228f1f77a1dc06ad06079 (commit)
via e0cd8fa5dd63fcbf8c291f66356ab565cd057cc9 (commit)
via dc1598b75cca6711f9bd233ac477031fb39dbca1 (commit)
via 6a39d3d26db6669fee7ea19d9aa9dbc9310923fb (commit)
via 4c97dae294f9274d55f254596aee1428c4c3a413 (commit)
via e1a4d000a0583d47a360dc04cdb8cdf9b0e6e1b1 (commit)
via 8f268ab4640dd61173cc2b79516cd8723476ee3d (commit)
via d3f7b508acf663660231a637a67360f9f2d37be5 (commit)
via 306b4e7333135cdbf119f4fafae4f18e1121a72f (commit)
via 3fe2706694e96e4ee54388d760b05c8dfd49b49f (commit)
via f7e2554a21910cd7bb82dec98b6d570c4609fdd3 (commit)
via 8be55cd4446e1a67bdc530d9d2febe66e46e61cf (commit)
via e6d1ada2b2baea7581ad1e181ae6a2f41d2ccc26 (commit)
via 3ba249204e625f7172c74bffab0748c736fe5d21 (commit)
via 248bf58e224c285c801d1509c9810625d8bf5079 (commit)
from 057918e0d6131a29856e98ff57723a90af11bd40 (commit)
Summary of changes:
.../MediaOperationsCore/MediaOperationsCoreIf.ice | 27 +-
src/CMakeLists.txt | 20 +-
src/MediaOperationStateReplicatorListener.cpp | 37 ++-
src/MediaOperationsCore.cpp | 133 +++++-
src/TranslatorOperation.cpp | 140 ++++++
src/TranslatorOperation.h | 117 +++++
src/TranslatorOperationFactory.cpp | 128 +++++
src/TranslatorOperationFactory.h | 107 ++++
src/TranslatorSink.cpp | 11 +-
src/TranslatorSink.h | 5 +-
src/g722.cpp | 210 ++++++++
src/{ulaw_alaw.h => g722.h} | 20 +-
src/resample.cpp | 180 +++++++
src/{ulaw_alaw.h => resample.h} | 27 +-
src/ulaw_alaw.cpp | 247 ++--------
src/ulaw_alaw.h | 15 +-
test/TestMediaOperations.cpp | 518 +++++++++++++++++++-
17 files changed, 1642 insertions(+), 300 deletions(-)
create mode 100644 src/TranslatorOperation.cpp
create mode 100644 src/TranslatorOperation.h
create mode 100644 src/TranslatorOperationFactory.cpp
create mode 100644 src/TranslatorOperationFactory.h
create mode 100644 src/g722.cpp
copy src/{ulaw_alaw.h => g722.h} (62%)
create mode 100644 src/resample.cpp
copy src/{ulaw_alaw.h => resample.h} (58%)
- Log -----------------------------------------------------------------
commit 4456735a649c3828f7f228f1f77a1dc06ad06079
Merge: 057918e e0cd8fa
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Sep 14 10:21:53 2011 -0500
Merge branch 'resample'
Conflicts:
src/ulaw_alaw.cpp
commit e0cd8fa5dd63fcbf8c291f66356ab565cd057cc9
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Sep 1 11:29:07 2011 -0500
Place common code into common functions.
diff --git a/src/MediaOperationStateReplicatorListener.cpp b/src/MediaOperationStateReplicatorListener.cpp
index 7cfb0f0..2943d21 100644
--- a/src/MediaOperationStateReplicatorListener.cpp
+++ b/src/MediaOperationStateReplicatorListener.cpp
@@ -15,7 +15,10 @@
*/
#include "MediaOperationStateReplicator.h"
+#include "TranslatorOperationFactory.h"
#include "ulaw_alaw.h"
+#include "resample.h"
+#include "g722.h"
namespace AsteriskSCF
{
@@ -51,6 +54,14 @@ void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
{
mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId));
}
+ void visitResamplerMediaOperationStateItem(const ResamplerMediaOperationStateItemPtr& resample)
+ {
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(resample->operationId));
+ }
+ void visitG722MediaOperationStateItem(const G722MediaOperationStateItemPtr& g722)
+ {
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(g722->operationId));
+ }
Ice::ObjectAdapterPtr mAdapter;
};
@@ -77,15 +88,35 @@ void MediaOperationStateReplicatorListenerImpl::stateSet(
{
UlawAlawFactoryPtr factory = UlawAlawFactoryPtr::dynamicCast(mAdapter->find(ulawAlaw->factoryId));
+ createTranslationMediaOperation(factory, ulawAlaw);
+ }
+
+ void visitResamplerMediaOperationStateItem(const ResamplerMediaOperationStateItemPtr& resample)
+ {
+ ResampleFactoryPtr factory = ResampleFactoryPtr::dynamicCast(mAdapter->find(resample->factoryId));
+
+ createTranslationMediaOperation(factory, resample);
+ }
+
+ void visitG722MediaOperationStateItem(const G722MediaOperationStateItemPtr& g722)
+ {
+ G722FactoryPtr factory = G722FactoryPtr::dynamicCast(mAdapter->find(g722->factoryId));
+
+ createTranslationMediaOperation(factory, g722);
+ }
+
+ void createTranslationMediaOperation(const TranslatorOperationFactoryPtr& factory,
+ const TranslatorMediaOperationStateItemPtr& item)
+ {
if (!factory)
{
return;
}
factory->createMediaOperation(
- ulawAlaw->sourceFormat,
- ulawAlaw->sinkFormat,
- ulawAlaw->operationId);
+ item->sourceFormat,
+ item->sinkFormat,
+ item->operationId);
}
Ice::ObjectAdapterPtr mAdapter;
};
commit dc1598b75cca6711f9bd233ac477031fb39dbca1
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Sep 1 11:03:06 2011 -0500
Add documentation and change some bad function names.
diff --git a/src/TranslatorOperation.h b/src/TranslatorOperation.h
index bb9f4c7..152a469 100644
--- a/src/TranslatorOperation.h
+++ b/src/TranslatorOperation.h
@@ -30,6 +30,9 @@ namespace AsteriskSCF
namespace MediaOperationsCore
{
+/**
+ * Base class for Media operations that translate between formats
+ */
class TranslatorOperation : public AsteriskSCF::Media::V1::MediaOperation
{
public:
@@ -43,16 +46,59 @@ public:
virtual ~TranslatorOperation();
+ /**
+ * Set state in the state replicator.
+ *
+ * The only reason that subclasses should override this is if they have
+ * any specific state they need to replicate in addition to the common
+ * traits all translators replicate.
+ *
+ * If this is overridden, the best approach to take is to set fields within
+ * your state item and then call TranslatorOperation::setState().
+ */
virtual void setState();
+ /**
+ * Remove state in the state replicator.
+ *
+ * The only reason that subclasses should override this is if they have
+ * specific state they need to replicate in addition to the common
+ * traits all translators replicate.
+ *
+ * If this is overridden, the best approach to take is to set fields within
+ * your state item and then call TranslatorOperation::removeState().
+ */
virtual void removeState();
+ /**
+ * Add objects to the object adapter.
+ *
+ * The only reason to override this would be if additional servants should
+ * be added to the object adapter. Be sure to call TranslatorOperation::activate(id)
+ * in your override.
+ *
+ * This will add the operation, along with its source and sink to the object adapter.
+ */
virtual AsteriskSCF::Media::V1::MediaOperationPrx activate(const std::string& id);
- virtual void destroy(const Ice::Current&);
+ /**
+ * Remove items from the object adapter.
+ *
+ * NOTE: It may seem like this should be virtual, so that custom servants added
+ * during activate() could be removed here. However, this should be done in an
+ * overridden destructor instead. Otherwise, replicated TranslatorOperations
+ * would not properly remove servants from their object adapter.
+ */
+ void destroy(const Ice::Current&);
+ /**
+ * Get the stream source for this operation.
+ */
AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
+ /**
+ * Get the stream sink for this operation
+ */
AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&);
protected:
diff --git a/src/TranslatorOperationFactory.cpp b/src/TranslatorOperationFactory.cpp
index bce48d7..82137fb 100644
--- a/src/TranslatorOperationFactory.cpp
+++ b/src/TranslatorOperationFactory.cpp
@@ -38,6 +38,8 @@ TranslatorOperationFactory::TranslatorOperationFactory(
mLocatorParams->service = MediaOperationDiscoveryTranslatorService;
}
+TranslatorOperationFactory::~TranslatorOperationFactory() { }
+
MediaOperationPrx TranslatorOperationFactory::createMediaOperation(
const StreamSourcePrx& source,
const StreamSinkPrx& sink,
@@ -56,7 +58,7 @@ MediaOperationPrx TranslatorOperationFactory::createMediaOperation(
sourceFormats.end(),
mTranslations.begin(),
mTranslations.end(),
- TranslatorOperationFactory::formatsEqual2);
+ TranslatorOperationFactory::formatsEqualMap);
if (supportedInput == sourceFormats.end())
{
@@ -76,7 +78,7 @@ MediaOperationPrx TranslatorOperationFactory::createMediaOperation(
sinkFormats.end(),
mTranslations[(*supportedInput)->name].begin(),
mTranslations[(*supportedInput)->name].end(),
- TranslatorOperationFactory::formatsEqual1);
+ TranslatorOperationFactory::formatsEqual);
if (supportedOutput == sinkFormats.end())
{
@@ -108,14 +110,14 @@ void TranslatorOperationFactory::addTranslation(
mLocatorParams->attributes.push_back(attrs);
}
-bool TranslatorOperationFactory::formatsEqual1(
+bool TranslatorOperationFactory::formatsEqual(
const FormatPtr& lhs,
const FormatPtr& rhs)
{
return lhs->name == rhs->name;
}
-bool TranslatorOperationFactory::formatsEqual2(
+bool TranslatorOperationFactory::formatsEqualMap(
const FormatPtr& lhs,
const std::pair<std::string, FormatSeq>& rhs)
{
diff --git a/src/TranslatorOperationFactory.h b/src/TranslatorOperationFactory.h
index d95389f..ee2a279 100644
--- a/src/TranslatorOperationFactory.h
+++ b/src/TranslatorOperationFactory.h
@@ -24,6 +24,10 @@ namespace AsteriskSCF
namespace MediaOperationsCore
{
+/**
+ * Base class for Media Operation Factories that
+ * produce translators.
+ */
class TranslatorOperationFactory : public MediaOperationFactoryImpl
{
public:
@@ -34,32 +38,66 @@ public:
const MediaOperationReplicationContextPtr& replicationContext,
const std::string& name);
+ virtual ~TranslatorOperationFactory();
+
+ /**
+ * Overload of the slice MediaOperationFactory::createMediaOperation
+ * method.
+ *
+ * This will use the translation map in order to determine if the source
+ * and sink parameters support formats that this factory knows about.
+ * It will then call the below createMediaOperation() method once
+ * the formats have been determined.
+ */
AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
const AsteriskSCF::Media::V1::StreamSourcePrx& source,
const AsteriskSCF::Media::V1::StreamSinkPrx& sink,
const Ice::Current&);
+ /**
+ * Pure virtual function to create a media operation.
+ *
+ * Create a media operation with the given formats.
+ *
+ * @param sourceFormat The format for the media operation's source to use.
+ * @param sinkFormat The format for the media operation's sink to use.
+ * @param operationId The Ice identification string to use when adding the operation
+ * to the object adapter.
+ * @return A proxy to the newly created media operation
+ */
virtual AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
const AsteriskSCF::Media::V1::FormatPtr& sinkFormat,
const std::string& operationId) = 0;
+ /**
+ * Add a translation supported by the factory.
+ *
+ * @param inFormat The input format for translation
+ * @param outFormat The output format for translation
+ * @param cost The cost of the translation. Units for cost are
+ * undetermined at this time. A higher cost implies a
+ */
void addTranslation(
- const AsteriskSCF::Media::V1::FormatPtr&,
- const AsteriskSCF::Media::V1::FormatPtr&,
+ const AsteriskSCF::Media::V1::FormatPtr& inFormat,
+ const AsteriskSCF::Media::V1::FormatPtr& outFormat,
int cost);
- static bool formatsEqual1(
+ /**
+ * Handy function to compare two formats. Useful for predicates
+ * in STL algorithms. Returns true if the formats are the same.
+ */
+ static bool formatsEqual(
const AsteriskSCF::Media::V1::FormatPtr& lhs,
const AsteriskSCF::Media::V1::FormatPtr& rhs);
- static bool formatsEqual2(
- const AsteriskSCF::Media::V1::FormatPtr& lhs,
- const std::pair<std::string, AsteriskSCF::Media::V1::FormatSeq>& rhs);
-
private:
typedef std::map<std::string, AsteriskSCF::Media::V1::FormatSeq> TranslationMap;
+ static bool formatsEqualMap(
+ const AsteriskSCF::Media::V1::FormatPtr& lhs,
+ const std::pair<std::string, AsteriskSCF::Media::V1::FormatSeq>& rhs);
+
TranslationMap mTranslations;
};
diff --git a/src/g722.cpp b/src/g722.cpp
index 112bbec..038110d 100644
--- a/src/g722.cpp
+++ b/src/g722.cpp
@@ -112,7 +112,7 @@ private:
FramePtr translate(const FramePtr inFrame)
{
- if (!TranslatorOperationFactory::formatsEqual1(inFrame->mediaFormat, mInputFormat))
+ if (!TranslatorOperationFactory::formatsEqual(inFrame->mediaFormat, mInputFormat))
{
mLogger(Error) << "Cannot translate frame because the format is not what we expect.";
throw UnsupportedMediaFormatException();
diff --git a/src/resample.cpp b/src/resample.cpp
index de4cb64..572bc1a 100644
--- a/src/resample.cpp
+++ b/src/resample.cpp
@@ -26,16 +26,6 @@
using namespace AsteriskSCF::Media::V1;
-namespace
-{
-
-bool formatCompare(const FormatPtr& format1, const FormatPtr& format2)
-{
- return format1->name == format2->name;
-}
-
-};
-
namespace AsteriskSCF
{
@@ -85,7 +75,7 @@ private:
FramePtr translate(const FramePtr inFrame)
{
- if (!formatCompare(inFrame->mediaFormat, mInputFormat))
+ if (!TranslatorOperationFactory::formatsEqual(inFrame->mediaFormat, mInputFormat))
{
mLogger(Error) << "Cannot resample frame because the format is not what was expected";
throw UnsupportedMediaFormatException();
commit 6a39d3d26db6669fee7ea19d9aa9dbc9310923fb
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Aug 31 19:59:08 2011 -0500
Add G.722 tests. They pass.
diff --git a/src/g722.cpp b/src/g722.cpp
index 7d60640..112bbec 100644
--- a/src/g722.cpp
+++ b/src/g722.cpp
@@ -76,7 +76,7 @@ private:
outsamples = g722_decode(&mDecodeToSlin8, outbuffer16, &inPayload->payload.front(), inFormat->frameSize);
}
- ShortSeqPayloadPtr outPayload(new ShortSeqPayload(Ice::ShortSeq(outsamples)));
+ ShortSeqPayloadPtr outPayload(new ShortSeqPayload(Ice::ShortSeq(outbuffer16, outbuffer16 + outsamples)));
outFormat->frameSize = outsamples;
return new Frame(outFormat, outPayload);
}
@@ -105,7 +105,7 @@ private:
outlen = g722_encode(&mEncodeFromSlin8, outbuffer8, &inPayload->payload.front(), inFormat->frameSize);
}
- ByteSeqPayloadPtr outPayload(new ByteSeqPayload(Ice::ByteSeq(outlen)));
+ ByteSeqPayloadPtr outPayload(new ByteSeqPayload(Ice::ByteSeq(outbuffer8, outbuffer8 + outlen)));
outFormat->frameSize = outlen;
return new Frame(outFormat, outPayload);
}
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index 2df6731..f4bec35 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -60,6 +60,8 @@ public:
AudioFormatPtr slin16;
+ AudioFormatPtr g722;
+
TestStreamSinkPtr ulawSink;
StreamSinkPrx ulawSinkProxy;
@@ -78,6 +80,10 @@ public:
TestStreamSourcePtr alawSource;
+ TestStreamSinkPtr g722Sink;
+
+ StreamSinkPrx g722SinkProxy;
+
StreamSourcePrx alawSourceProxy;
TestStreamSourcePtr ulawSource;
@@ -92,6 +98,10 @@ public:
StreamSourcePrx slin16SourceProxy;
+ TestStreamSourcePtr g722Source;
+
+ StreamSourcePrx g722SourceProxy;
+
FramePtr sampleAlawFrame;
size_t sampleAlawFrameSize;
@@ -107,6 +117,10 @@ public:
FramePtr sampleSlin16Frame;
size_t sampleSlin16FrameSize;
+
+ FramePtr sampleG722Frame;
+
+ size_t sampleG722FrameSize;
};
static SharedTestData Testbed;
@@ -170,6 +184,30 @@ static uint16_t sampleSlin16[] = {
0x90c0, 0xc3c6, 0xc9cc, 0xcfd2,
};
+//Copied from Asterisk's ex_g722.h file
+static uint8_t sampleG722[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
/**
* Wrapper class around pj_thread_desc.
* (copied from PJSipManager.h in the sip repo)
@@ -274,6 +312,9 @@ struct GlobalIceFixture
Testbed.slin16->name = SignedLinear16Name;
Testbed.slin16->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.sampleAlawFrameSize = sizeof(sampleAlaw);
@@ -287,6 +328,9 @@ struct GlobalIceFixture
ShortSeqPayloadPtr slin16Payload(new ShortSeqPayload(Ice::ShortSeq(sampleSlin16, sampleSlin16 + (sizeof(sampleSlin16) / 2))));
Testbed.sampleSlin16Frame = new Frame(Testbed.slin16, slin16Payload);
Testbed.sampleSlin16FrameSize = slin16Payload->payload.size();
+
+ Testbed.sampleG722Frame = new Frame(Testbed.g722, new ByteSeqPayload(Ice::ByteSeq(sampleG722, sampleG722 + sizeof(sampleG722))));
+ Testbed.sampleG722FrameSize = sizeof(sampleG722);
}
catch (const Ice::Exception& ex)
{
@@ -344,6 +388,12 @@ public:
Testbed.slin16Sink = new TestStreamSink(Testbed.slin16);
Testbed.slin16SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin16Sink));
+
+ Testbed.g722Source = new TestStreamSource(Testbed.g722);
+ Testbed.g722SourceProxy = StreamSourcePrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.g722Source));
+
+ Testbed.g722Sink = new TestStreamSink(Testbed.g722);
+ Testbed.g722SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.g722Sink));
}
~PerTestFixture()
{
@@ -354,6 +404,12 @@ public:
Testbed.adapter->remove(Testbed.alawSinkProxy->ice_getIdentity());
Testbed.adapter->remove(Testbed.ulawSourceProxy->ice_getIdentity());
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.slin16SourceProxy->ice_getIdentity());
+ Testbed.adapter->remove(Testbed.slin16SinkProxy->ice_getIdentity());
+ Testbed.adapter->remove(Testbed.g722SourceProxy->ice_getIdentity());
+ Testbed.adapter->remove(Testbed.g722SinkProxy->ice_getIdentity());
}
};
@@ -667,3 +723,240 @@ BOOST_FIXTURE_TEST_CASE(resample16To8, PerTestFixture)
BOOST_CHECK((int) payload->payload.size() == audio->frameSize);
}
}
+
+BOOST_FIXTURE_TEST_CASE(slin8toG722, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+
+ //For this test, we have to base the resultant frame on the size of the input frame.
+
+ Testbed.g722->frameSize = Testbed.sampleG722FrameSize;
+
+ MediaOperationServiceLocatorParamsPtr slinToG722Params = createLocatorParams(Testbed.slin8, Testbed.g722);
+
+ MediaOperationFactoryPrx slinToG722Factory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slinToG722Params));
+
+ MediaOperationPrx slinToG722Translator =
+ slinToG722Factory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.g722SinkProxy);
+
+ StreamSinkPrx translatorSink = slinToG722Translator->getSink();
+ StreamSourcePrx translatorSource = slinToG722Translator->getSource();
+
+ Testbed.slin8SourceProxy->addSink(translatorSink);
+ Testbed.g722SinkProxy->setSource(translatorSource);
+
+ translatorSource->addSink(Testbed.g722SinkProxy);
+ translatorSink->setSource(Testbed.slin8SourceProxy);
+
+ 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());
+ }
+
+ FrameSeq framesWritten = Testbed.g722Sink->getFrames();
+
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ BOOST_CHECK(G722Ptr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ AudioFormatPtr audio = AudioFormatPtr::dynamicCast((*iter)->mediaFormat);
+
+ BOOST_REQUIRE(audio != 0);
+
+ BOOST_CHECK((int) payload->payload.size() == audio->frameSize);
+ }
+}
+
+BOOST_FIXTURE_TEST_CASE(slin16toG722, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+
+ //For this test, we have to base the resultant frame on the size of the input frame.
+
+ Testbed.g722->frameSize = Testbed.sampleG722FrameSize;
+
+ MediaOperationServiceLocatorParamsPtr slinToG722Params = createLocatorParams(Testbed.slin16, Testbed.g722);
+
+ MediaOperationFactoryPrx slinToG722Factory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(slinToG722Params));
+
+ MediaOperationPrx slinToG722Translator =
+ slinToG722Factory->createMediaOperation(Testbed.slin16SourceProxy, Testbed.g722SinkProxy);
+
+ StreamSinkPrx translatorSink = slinToG722Translator->getSink();
+ StreamSourcePrx translatorSource = slinToG722Translator->getSource();
+
+ Testbed.slin16SourceProxy->addSink(translatorSink);
+ Testbed.g722SinkProxy->setSource(translatorSource);
+
+ translatorSource->addSink(Testbed.g722SinkProxy);
+ translatorSink->setSource(Testbed.slin16SourceProxy);
+
+ FrameSeq slin16Frames(numFramesToTranslate, Testbed.sampleSlin16Frame);
+
+ try
+ {
+ Testbed.slin16Source->feedFramesToTranslator(slin16Frames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate slin16 frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ FrameSeq framesWritten = Testbed.g722Sink->getFrames();
+
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ BOOST_CHECK(G722Ptr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ AudioFormatPtr audio = AudioFormatPtr::dynamicCast((*iter)->mediaFormat);
+
+ BOOST_REQUIRE(audio != 0);
+
+ BOOST_CHECK((int) payload->payload.size() == audio->frameSize);
+ }
+}
+
+BOOST_FIXTURE_TEST_CASE(g722ToSlin8, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+
+ //For this test, we have to base the resultant frame on the size of the input frame.
+
+ Testbed.slin8->frameSize = Testbed.sampleSlin8FrameSize;
+
+ MediaOperationServiceLocatorParamsPtr g722ToSlinParams = createLocatorParams(Testbed.g722, Testbed.slin8);
+
+ MediaOperationFactoryPrx g722ToSlinFactory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(g722ToSlinParams));
+
+ MediaOperationPrx g722ToSlinTranslator =
+ g722ToSlinFactory->createMediaOperation(Testbed.g722SourceProxy, Testbed.slin8SinkProxy);
+
+ StreamSinkPrx translatorSink = g722ToSlinTranslator->getSink();
+ StreamSourcePrx translatorSource = g722ToSlinTranslator->getSource();
+
+ Testbed.g722SourceProxy->addSink(translatorSink);
+ Testbed.slin8SinkProxy->setSource(translatorSource);
+
+ translatorSource->addSink(Testbed.slin8SinkProxy);
+ translatorSink->setSource(Testbed.g722SourceProxy);
+
+ FrameSeq g722Frames(numFramesToTranslate, Testbed.sampleG722Frame);
+
+ try
+ {
+ Testbed.g722Source->feedFramesToTranslator(g722Frames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate G.722 frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ FrameSeq framesWritten = Testbed.slin8Sink->getFrames();
+
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ BOOST_CHECK(SignedLinearPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ShortSeqPayloadPtr payload = ShortSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ AudioFormatPtr audio = AudioFormatPtr::dynamicCast((*iter)->mediaFormat);
+
+ BOOST_REQUIRE(audio != 0);
+
+ BOOST_CHECK((int) payload->payload.size() == audio->frameSize);
+ }
+}
+
+BOOST_FIXTURE_TEST_CASE(g722ToSlin16, PerTestFixture)
+{
+ size_t numFramesToTranslate = 10;
+
+ //For this test, we have to base the resultant frame on the size of the input frame.
+
+ Testbed.slin16->frameSize = Testbed.sampleSlin16FrameSize;
+
+ MediaOperationServiceLocatorParamsPtr g722ToSlinParams = createLocatorParams(Testbed.g722, Testbed.slin16);
+
+ MediaOperationFactoryPrx g722ToSlinFactory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(g722ToSlinParams));
+
+ MediaOperationPrx g722ToSlinTranslator =
+ g722ToSlinFactory->createMediaOperation(Testbed.g722SourceProxy, Testbed.slin16SinkProxy);
+
+ StreamSinkPrx translatorSink = g722ToSlinTranslator->getSink();
+ StreamSourcePrx translatorSource = g722ToSlinTranslator->getSource();
+
+ Testbed.g722SourceProxy->addSink(translatorSink);
+ Testbed.slin16SinkProxy->setSource(translatorSource);
+
+ translatorSource->addSink(Testbed.slin16SinkProxy);
+ translatorSink->setSource(Testbed.g722SourceProxy);
+
+ FrameSeq g722Frames(numFramesToTranslate, Testbed.sampleG722Frame);
+
+ try
+ {
+ Testbed.g722Source->feedFramesToTranslator(g722Frames);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ std::stringstream str;
+ str << "Exception caught trying to translate G.722 frames: " << ex.what();
+ BOOST_FAIL(str.str());
+ }
+
+ FrameSeq framesWritten = Testbed.slin16Sink->getFrames();
+
+ BOOST_CHECK(framesWritten.size() == numFramesToTranslate);
+
+ for (FrameSeq::iterator iter = framesWritten.begin();
+ iter != framesWritten.end(); ++iter)
+ {
+ BOOST_CHECK(SignedLinearPtr::dynamicCast((*iter)->mediaFormat) != 0);
+
+ ShortSeqPayloadPtr payload = ShortSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_REQUIRE(payload != 0);
+
+ AudioFormatPtr audio = AudioFormatPtr::dynamicCast((*iter)->mediaFormat);
+
+ BOOST_REQUIRE(audio != 0);
+
+ BOOST_CHECK((int) payload->payload.size() == audio->frameSize);
+ }
+}
+
commit 4c97dae294f9274d55f254596aee1428c4c3a413
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Aug 31 15:37:51 2011 -0500
G.722 translator has been written now.
Next step: tests!
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 75f6102..b7aee9c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,9 @@ astscf_component_add_files(MediaOperationsCore resample.h)
astscf_component_add_files(MediaOperationsCore resample.cpp)
astscf_component_add_files(MediaOperationsCore g722.h)
astscf_component_add_files(MediaOperationsCore g722.cpp)
+astscf_component_add_files(MediaOperationsCore g722/g722_encode.c)
+astscf_component_add_files(MediaOperationsCore g722/g722_decode.c)
+astscf_component_add_files(MediaOperationsCore g722/g722.h)
astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.h)
astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationsCore.cpp)
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index e78218e..296d41b 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -25,6 +25,7 @@
#include "MediaOperationFactoryImpl.h"
#include "ulaw_alaw.h"
#include "resample.h"
+#include "g722.h"
using namespace AsteriskSCF::System::Logging;
@@ -190,6 +191,10 @@ private:
lg(Debug) << "Creating Resampler";
createAndRegisterFactory(new ResampleFactory(getServiceAdapter(), lg,
boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext())));
+
+ lg(Debug) << "Creating G.722 Factory";
+ createAndRegisterFactory(new G722Factory(getServiceAdapter(), lg,
+ boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext())));
}
void locateStateReplicator()
diff --git a/src/g722.cpp b/src/g722.cpp
index 47cfb4b..7d60640 100644
--- a/src/g722.cpp
+++ b/src/g722.cpp
@@ -16,6 +16,8 @@
#include <AsteriskSCF/Media/Formats/AudioFormats.h>
+#include "g722/g722.h"
+
#include "g722.h"
#include "TranslatorOperation.h"
@@ -42,13 +44,100 @@ private:
const Logger& logger)
: Translator(source, inputFormat, outputFormat, logger)
{
+ //XXX Do we have any intention of supporting 48 Kbps or
+ //56 Kbps G.722?
+ g722_encode_init(&mEncodeFromSlin8, 64000, G722_SAMPLE_RATE_8000);
+ g722_decode_init(&mDecodeToSlin8, 64000, G722_SAMPLE_RATE_8000);
+ g722_encode_init(&mEncodeFromSlin16, 64000, 0);
+ g722_decode_init(&mDecodeToSlin16, 64000, 0);
+ }
+
+ FramePtr translateFromG722(const FramePtr& inFrame)
+ {
+ AudioFormatPtr inFormat = AudioFormatPtr::dynamicCast(inFrame->mediaFormat);
+ AudioFormatPtr outFormat = AudioFormatPtr::dynamicCast(mOutputFormat);
+
+ ByteSeqPayloadPtr inPayload = ByteSeqPayloadPtr::dynamicCast(inFrame->payload);
+
+ if (!inPayload)
+ {
+ throw UnsupportedMediaFormatException();
+ }
+
+ int outsamples;
+ if (outFormat->name == SignedLinear16Name)
+ {
+ //Translating to slin16
+ outsamples = g722_decode(&mDecodeToSlin16, outbuffer16, &inPayload->payload.front(), inFormat->frameSize);
+ }
+ else
+ {
+ //Translating to slin8
+ outsamples = g722_decode(&mDecodeToSlin8, outbuffer16, &inPayload->payload.front(), inFormat->frameSize);
+ }
+
+ ShortSeqPayloadPtr outPayload(new ShortSeqPayload(Ice::ShortSeq(outsamples)));
+ outFormat->frameSize = outsamples;
+ return new Frame(outFormat, outPayload);
+ }
+
+ FramePtr translateToG722(const FramePtr& inFrame)
+ {
+ AudioFormatPtr inFormat = AudioFormatPtr::dynamicCast(inFrame->mediaFormat);
+ AudioFormatPtr outFormat = AudioFormatPtr::dynamicCast(mOutputFormat);
+
+ ShortSeqPayloadPtr inPayload = ShortSeqPayloadPtr::dynamicCast(inFrame->payload);
+
+ if (!inPayload)
+ {
+ throw UnsupportedMediaFormatException();
+ }
+
+ int outlen;
+ if (inFormat->name == SignedLinear16Name)
+ {
+ //Translating from slin16
+ outlen = g722_encode(&mEncodeFromSlin16, outbuffer8, &inPayload->payload.front(), inFormat->frameSize);
+ }
+ else
+ {
+ //Translating from slin8
+ outlen = g722_encode(&mEncodeFromSlin8, outbuffer8, &inPayload->payload.front(), inFormat->frameSize);
+ }
+
+ ByteSeqPayloadPtr outPayload(new ByteSeqPayload(Ice::ByteSeq(outlen)));
+ outFormat->frameSize = outlen;
+ return new Frame(outFormat, outPayload);
}
- FramePtr translate(const FramePtr)
+ FramePtr translate(const FramePtr inFrame)
{
- //stub
- return 0;
+ if (!TranslatorOperationFactory::formatsEqual1(inFrame->mediaFormat, mInputFormat))
+ {
+ mLogger(Error) << "Cannot translate frame because the format is not what we expect.";
+ throw UnsupportedMediaFormatException();
+ }
+
+ if (inFrame->mediaFormat->name == G722Name)
+ {
+ return translateFromG722(inFrame);
+ }
+ else
+ {
+ return translateToG722(inFrame);
+ }
}
+ private:
+ g722_encode_state_t mEncodeFromSlin8;
+ g722_decode_state_t mDecodeToSlin8;
+ g722_encode_state_t mEncodeFromSlin16;
+ g722_decode_state_t mDecodeToSlin16;
+ //XXX Buffer sizes gotten from Asterisk.
+ //It's *highly* unlikely we need buffers this
+ //large since we aren't accumulating samples
+ //the same way that Asterisk's translators do.
+ uint8_t outbuffer8[8096];
+ int16_t outbuffer16[4048];
};
public:
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index b6aeded..2d3e2a9 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -75,11 +75,6 @@ private:
FramePtr outFrame;
Ice::ByteSeq outPayload;
- //If we wanted to do things the "correct" way here, we'd call on the format
- //operation in order to decode the frame payload and then re-encode it after
- //we translated. But that amounts to way too many unnecessary RPCs. Since
- //we know of the attributes of the formats, we'll do things the shortcut way.
-
ByteSeqPayloadPtr inPayload = ByteSeqPayloadPtr::dynamicCast(inFrame->payload);
if (!inPayload)
{
commit e1a4d000a0583d47a360dc04cdb8cdf9b0e6e1b1
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Aug 31 09:52:56 2011 -0500
Adjust the addTranslation method to take individual translations instead of multiple.
I realized that the cost of translation could differ per translation, so they need
to be added individually.
diff --git a/src/TranslatorOperationFactory.cpp b/src/TranslatorOperationFactory.cpp
index ba13657..bce48d7 100644
--- a/src/TranslatorOperationFactory.cpp
+++ b/src/TranslatorOperationFactory.cpp
@@ -95,28 +95,17 @@ MediaOperationPrx TranslatorOperationFactory::createMediaOperation(
void TranslatorOperationFactory::addTranslation(
const FormatPtr& inFormat,
- const FormatSeq& outFormats,
+ const FormatPtr& outFormat,
int cost)
{
- std::pair<TranslationMap::iterator, bool> inserted =
- mTranslations.insert(std::make_pair(inFormat->name, outFormats));
+ mTranslations[inFormat->name].push_back(outFormat);
- if (inserted.second == false)
- {
- mLogger(Error) << "There was an error trying to add a translation to the factory?";
- return;
- }
+ MediaOperationAttributes attrs;
+ attrs.inputFormat = inFormat;
+ attrs.outputFormat = outFormat;
+ attrs.cost = cost;
- for (FormatSeq::iterator iter = inserted.first->second.begin();
- iter != inserted.first->second.end(); ++iter)
- {
- MediaOperationAttributes attrs;
- attrs.inputFormat = inFormat;
- attrs.outputFormat = *iter;
- attrs.cost = cost;
-
- mLocatorParams->attributes.push_back(attrs);
- }
+ mLocatorParams->attributes.push_back(attrs);
}
bool TranslatorOperationFactory::formatsEqual1(
diff --git a/src/TranslatorOperationFactory.h b/src/TranslatorOperationFactory.h
index 50cdb9a..d95389f 100644
--- a/src/TranslatorOperationFactory.h
+++ b/src/TranslatorOperationFactory.h
@@ -46,7 +46,7 @@ public:
void addTranslation(
const AsteriskSCF::Media::V1::FormatPtr&,
- const AsteriskSCF::Media::V1::FormatSeq&,
+ const AsteriskSCF::Media::V1::FormatPtr&,
int cost);
static bool formatsEqual1(
diff --git a/src/g722.cpp b/src/g722.cpp
index a1b9a20..47cfb4b 100644
--- a/src/g722.cpp
+++ b/src/g722.cpp
@@ -111,16 +111,10 @@ void G722Factory::buildTranslations()
FormatPtr g722 = new G722();
g722->name = G722Name;
- FormatSeq slins;
- slins.push_back(slin8);
- slins.push_back(slin16);
-
- FormatSeq g722Seq;
- g722Seq.push_back(g722);
-
- addTranslation(g722, slins, 100);
- addTranslation(slin8, g722Seq, 100);
- addTranslation(slin16, g722Seq, 100);
+ addTranslation(g722, slin8, 100);
+ addTranslation(g722, slin16, 100);
+ addTranslation(slin8, g722, 100);
+ addTranslation(slin16, g722, 100);
}
} //end namespace MediaOperationsCore
diff --git a/src/resample.cpp b/src/resample.cpp
index d7b36b6..de4cb64 100644
--- a/src/resample.cpp
+++ b/src/resample.cpp
@@ -182,14 +182,8 @@ void ResampleFactory::buildTranslations()
FormatPtr slin16 = new SignedLinear();
slin16->name = SignedLinear16Name;
- FormatSeq slin8Seq;
- slin8Seq.push_back(slin8);
-
- FormatSeq slin16Seq;
- slin16Seq.push_back(slin16);
-
- addTranslation(slin8, slin16Seq, 100);
- addTranslation(slin16, slin8Seq, 100);
+ addTranslation(slin8, slin16, 100);
+ addTranslation(slin16, slin8, 100);
}
}
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 13141ab..b6aeded 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -139,14 +139,8 @@ void UlawAlawFactory::buildTranslations()
FormatPtr alaw = new G711aLAW();
alaw->name = G711aLAWName;
- FormatSeq ulawSeq;
- ulawSeq.push_back(ulaw);
-
- FormatSeq alawSeq;
- alawSeq.push_back(alaw);
-
- addTranslation(ulaw, alawSeq, 100);
- addTranslation(alaw, ulawSeq, 100);
+ addTranslation(ulaw, alaw, 100);
+ addTranslation(alaw, ulaw, 100);
}
MediaOperationPrx UlawAlawFactory::createMediaOperation(
commit 8f268ab4640dd61173cc2b79516cd8723476ee3d
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 30 17:28:31 2011 -0500
Add g722 operation file.
The translator is just stubbed out for the moment.
diff --git a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
index 02a4f63..313bc60 100644
--- a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
@@ -99,6 +99,13 @@ class ResamplerMediaOperationStateItem extends TranslatorMediaOperationStateItem
{
};
+/**
+ * State item for G722 translators
+ */
+class G722MediaOperationStateItem extends TranslatorMediaOperationStateItem
+{
+};
+
interface MediaOperationStateReplicatorListener
{
void stateRemoved(Ice::StringSeq itemKeys);
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e4b02f7..75f6102 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,6 +16,8 @@ astscf_component_add_files(MediaOperationsCore ulaw_alaw.h)
astscf_component_add_files(MediaOperationsCore ulaw_alaw.cpp)
astscf_component_add_files(MediaOperationsCore resample.h)
astscf_component_add_files(MediaOperationsCore resample.cpp)
+astscf_component_add_files(MediaOperationsCore g722.h)
+astscf_component_add_files(MediaOperationsCore g722.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.h)
astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationsCore.cpp)
diff --git a/src/g722.cpp b/src/g722.cpp
new file mode 100644
index 0000000..a1b9a20
--- /dev/null
+++ b/src/g722.cpp
@@ -0,0 +1,127 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <AsteriskSCF/Media/Formats/AudioFormats.h>
+
+#include "g722.h"
+#include "TranslatorOperation.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Media::Formats::Audio::V1;
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
+
+class G722Operation : public TranslatorOperation
+{
+private:
+ class G722Translator : public Translator
+ {
+ public:
+ G722Translator (const TranslatorSourcePtr& source,
+ const FormatPtr& inputFormat,
+ const FormatPtr& outputFormat,
+ const Logger& logger)
+ : Translator(source, inputFormat, outputFormat, logger)
+ {
+ }
+
+ FramePtr translate(const FramePtr)
+ {
+ //stub
+ return 0;
+ }
+ };
+
+public:
+ G722Operation(const Ice::ObjectAdapterPtr& adapter,
+ const Logger& logger,
+ const FormatPtr& sourceFormat,
+ const FormatPtr& sinkFormat,
+ const Ice::Identity& factoryId,
+ const MediaOperationReplicationContextPtr& replicationContext)
+ : TranslatorOperation(
+ adapter,
+ logger,
+ sourceFormat,
+ sinkFormat,
+ factoryId,
+ replicationContext,
+ new G722MediaOperationStateItem)
+ {
+ mSink->setTranslator(new G722Translator(mSource, sinkFormat, sourceFormat, mLogger));
+ }
+};
+
+typedef IceUtil::Handle<G722Operation> G722OperationPtr;
+
+G722Factory::G722Factory(
+ const Ice::ObjectAdapterPtr& adapter,
+ const Logger& logger,
+ const MediaOperationReplicationContextPtr& replicationContext)
+ : TranslatorOperationFactory(adapter, logger, replicationContext, "G722Factory")
+{
+ buildTranslations();
+}
+
+MediaOperationPrx G722Factory::createMediaOperation(
+ const FormatPtr& sourceFormat,
+ const FormatPtr& sinkFormat,
+ const std::string& operationId)
+{
+ G722OperationPtr operation(
+ new G722Operation(
+ mAdapter,
+ mLogger,
+ sourceFormat,
+ sinkFormat,
+ getProxy()->ice_getIdentity(),
+ mReplicationContext));
+
+ MediaOperationPrx proxy = operation->activate(operationId);
+ return proxy;
+}
+
+void G722Factory::buildTranslations()
+{
+ FormatPtr slin8 = new SignedLinear();
+ slin8->name = SignedLinear8Name;
+
+ FormatPtr slin16 = new SignedLinear();
+ slin16->name = SignedLinear16Name;
+
+ FormatPtr g722 = new G722();
+ g722->name = G722Name;
+
+ FormatSeq slins;
+ slins.push_back(slin8);
+ slins.push_back(slin16);
+
+ FormatSeq g722Seq;
+ g722Seq.push_back(g722);
+
+ addTranslation(g722, slins, 100);
+ addTranslation(slin8, g722Seq, 100);
+ addTranslation(slin16, g722Seq, 100);
+}
+
+} //end namespace MediaOperationsCore
+} //end namespace AsteriskSCF
diff --git a/src/g722.h b/src/g722.h
new file mode 100644
index 0000000..801af1c
--- /dev/null
+++ b/src/g722.h
@@ -0,0 +1,44 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include "TranslatorOperationFactory.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class G722Factory : public TranslatorOperationFactory
+{
+public:
+ G722Factory(const Ice::ObjectAdapterPtr&,
+ const AsteriskSCF::System::Logging::Logger& logger,
+ const MediaOperationReplicationContextPtr& replicationContext);
+
+ AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
+ const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
+ const AsteriskSCF::Media::V1::FormatPtr& sinkFormat,
+ const std::string& operationId);
+private:
+ void buildTranslations();
+};
+
+typedef IceUtil::Handle<G722Factory> G722FactoryPtr;
+
+} //end namespace MediaOperationsCore
+} //end namespace AsteriskSCF
commit d3f7b508acf663660231a637a67360f9f2d37be5
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 30 16:53:46 2011 -0500
Create a common TranslatorOperation class and convert resampler and ulaw_alaw to use it.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4de238e..e4b02f7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,6 +10,8 @@ astscf_component_add_files(MediaOperationsCore TranslatorSource.cpp)
astscf_component_add_files(MediaOperationsCore TranslatorSource.h)
astscf_component_add_files(MediaOperationsCore TranslatorOperationFactory.cpp)
astscf_component_add_files(MediaOperationsCore TranslatorOperationFactory.h)
+astscf_component_add_files(MediaOperationsCore TranslatorOperation.cpp)
+astscf_component_add_files(MediaOperationsCore TranslatorOperation.h)
astscf_component_add_files(MediaOperationsCore ulaw_alaw.h)
astscf_component_add_files(MediaOperationsCore ulaw_alaw.cpp)
astscf_component_add_files(MediaOperationsCore resample.h)
diff --git a/src/TranslatorOperation.cpp b/src/TranslatorOperation.cpp
new file mode 100644
index 0000000..078016a
--- /dev/null
+++ b/src/TranslatorOperation.cpp
@@ -0,0 +1,140 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include "TranslatorOperation.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
+
+TranslatorOperation::TranslatorOperation(const Ice::ObjectAdapterPtr& adapter,
+ const Logger& logger,
+ const FormatPtr& sourceFormat,
+ const FormatPtr& sinkFormat,
+ const Ice::Identity& factoryId,
+ const MediaOperationReplicationContextPtr& replicationContext,
+ const TranslatorMediaOperationStateItemPtr& stateItem)
+ : mAdapter(adapter),
+ mLogger(logger),
+ mSource(new TranslatorSource(mLogger, sourceFormat)),
+ mSink(new TranslatorSink(mLogger, sinkFormat)),
+ mReplicationContext(replicationContext),
+ mStateItem(stateItem)
+{
+ mStateItem->sourceFormat = sourceFormat;
+ mStateItem->sinkFormat = sinkFormat;
+ mStateItem->factoryId = factoryId;
+}
+
+TranslatorOperation::~TranslatorOperation()
+{
+ mLogger(Debug) << "UlawAlawOperation destructor called";
+
+ try
+ {
+ mAdapter->remove(mSourceProxy->ice_getIdentity());
+ mAdapter->remove(mSinkProxy->ice_getIdentity());
+ }
+ catch (const Ice::Exception& ex)
+ {
+ mLogger(Error) << "Exception caught while trying to remove source and sink from object adapter";
+ }
+}
+
+void TranslatorOperation::setState()
+{
+ if (mReplicationContext->isReplicating() == false)
+ {
+ return;
+ }
+
+ try
+ {
+ MediaOperationStateItemSeq seq;
+ seq.push_back(mStateItem);
+ mReplicationContext->getReplicator().tryOneWay()->setState(seq);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
+ }
+}
+
+void TranslatorOperation::removeState()
+{
+ if (mReplicationContext->isReplicating() == false)
+ {
+ return;
+ }
+
+ try
+ {
+ MediaOperationStateItemSeq seq;
+ seq.push_back(mStateItem);
+ mReplicationContext->getReplicator().tryOneWay()->removeStateForItems(seq);
+ }
+ catch (const Ice::Exception& ex)
+ {
+ mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
+ }
+}
+
+MediaOperationPrx TranslatorOperation::activate(const std::string& id)
+{
+ mProxy =
+ MediaOperationPrx::uncheckedCast(mAdapter->add(this, mAdapter->getCommunicator()->stringToIdentity(id)));
+ mSinkProxy =
+ StreamSinkPrx::uncheckedCast(mAdapter->add(mSink, mAdapter->getCommunicator()->stringToIdentity(id + ".Sink")));
+ mSourceProxy =
+ StreamSourcePrx::uncheckedCast(mAdapter->add(mSource, mAdapter->getCommunicator()->stringToIdentity(id +".Source")));
+
+ mStateItem->operationId = mProxy->ice_getIdentity().name;
+
+ setState();
+
+ return mProxy;
+}
+
+StreamSourcePrx TranslatorOperation::getSource(const Ice::Current&)
+{
+ return mSourceProxy;
+}
+
+StreamSinkPrx TranslatorOperation::getSink(const Ice::Current&)
+{
+ return mSinkProxy;
+}
+
+void TranslatorOperation::destroy(const Ice::Current&)
+{
+ try
+ {
+ mAdapter->remove(mProxy->ice_getIdentity());
+ }
+ catch (Ice::Exception& ex)
+ {
+ mLogger(Error) << "Exception caught attempting to remove media operation from adapter: " << ex.what();
+ }
+}
+
+}
+}
diff --git a/src/TranslatorOperation.h b/src/TranslatorOperation.h
new file mode 100644
index 0000000..bb9f4c7
--- /dev/null
+++ b/src/TranslatorOperation.h
@@ -0,0 +1,71 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/Media/MediaOperationIf.h>
+#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
+
+#include "TranslatorSink.h"
+#include "TranslatorSource.h"
+#include "MediaOperationReplicationContext.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class TranslatorOperation : public AsteriskSCF::Media::V1::MediaOperation
+{
+public:
+ TranslatorOperation(const Ice::ObjectAdapterPtr& adapter,
+ const AsteriskSCF::System::Logging::Logger& logger,
+ const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
+ const AsteriskSCF::Media::V1::FormatPtr& sinkFormat,
+ const Ice::Identity& factoryId,
+ const MediaOperationReplicationContextPtr& replicationContext,
+ const AsteriskSCF::Replication::MediaOperationsCore::V1::TranslatorMediaOperationStateItemPtr& stateItem);
+
+ virtual ~TranslatorOperation();
+
+ virtual void setState();
+
+ virtual void removeState();
+
+ virtual AsteriskSCF::Media::V1::MediaOperationPrx activate(const std::string& id);
+
+ virtual void destroy(const Ice::Current&);
+
+ AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
+
+ AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&);
+
+protected:
+ Ice::ObjectAdapterPtr mAdapter;
+ AsteriskSCF::System::Logging::Logger mLogger;
+ AsteriskSCF::Media::V1::MediaOperationPrx mProxy;
+ TranslatorSourcePtr mSource;
+ AsteriskSCF::Media::V1::StreamSourcePrx mSourceProxy;
+ TranslatorSinkPtr mSink;
+ AsteriskSCF::Media::V1::StreamSinkPrx mSinkProxy;
+ MediaOperationReplicationContextPtr mReplicationContext;
+ AsteriskSCF::Replication::MediaOperationsCore::V1::TranslatorMediaOperationStateItemPtr mStateItem;
+};
+
+}
+}
diff --git a/src/TranslatorSink.cpp b/src/TranslatorSink.cpp
index 25bf231..81719b4 100644
--- a/src/TranslatorSink.cpp
+++ b/src/TranslatorSink.cpp
@@ -28,11 +28,9 @@ using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::System::Logging;
TranslatorSink::TranslatorSink(const Logger& logger,
- const FormatPtr& supportedFormat,
- const TranslatorPtr& translator)
+ const FormatPtr& supportedFormat)
: mLogger(logger),
- mId(IceUtil::generateUUID()),
- mTranslator(translator)
+ mId(IceUtil::generateUUID())
{
mSupportedFormats.push_back(supportedFormat);
}
@@ -47,6 +45,11 @@ void TranslatorSink::write(const FrameSeq& frames, const Ice::Current&)
mTranslator->translateFrames(frames);
}
+void TranslatorSink::setTranslator(const TranslatorPtr& translator)
+{
+ mTranslator = translator;
+}
+
void TranslatorSink::setSource(const StreamSourcePrx& source, const Ice::Current&)
{
mSource = source;
diff --git a/src/TranslatorSink.h b/src/TranslatorSink.h
index fa5bee5..80b07db 100644
--- a/src/TranslatorSink.h
+++ b/src/TranslatorSink.h
@@ -31,13 +31,14 @@ class TranslatorSink : public AsteriskSCF::Media::V1::StreamSink
{
public:
TranslatorSink(const AsteriskSCF::System::Logging::Logger& logger,
- const AsteriskSCF::Media::V1::FormatPtr& supportedFormat,
- const TranslatorPtr& translator);
+ const AsteriskSCF::Media::V1::FormatPtr& supportedFormat);
~TranslatorSink();
void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&);
+ void setTranslator(const TranslatorPtr& translator);
+
void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&);
AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
diff --git a/src/resample.cpp b/src/resample.cpp
index 9be11ac..d7b36b6 100644
--- a/src/resample.cpp
+++ b/src/resample.cpp
@@ -22,6 +22,7 @@
#include "TranslatorSource.h"
#include "Translator.h"
#include "TranslatorSink.h"
+#include "TranslatorOperation.h"
using namespace AsteriskSCF::Media::V1;
@@ -46,7 +47,7 @@ using namespace AsteriskSCF::Media::Formats::Audio::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
-class ResampleOperation : public MediaOperation
+class ResampleOperation : public TranslatorOperation
{
private:
class Resampler : public Translator
@@ -128,121 +129,17 @@ public:
const Ice::Identity& factoryId,
const MediaOperationReplicationContextPtr& replicationContext,
pj_caching_pool *cachingPool)
- : mAdapter(adapter),
- mLogger(logger),
- mStateItem(new ResamplerMediaOperationStateItem),
- mSource(new TranslatorSource(mLogger, sourceFormat)),
- mSink(new TranslatorSink(mLogger, sinkFormat, new Resampler(mSource, sinkFormat, sourceFormat, mLogger, cachingPool))),
- mReplicationContext(replicationContext)
- {
- mStateItem->sourceFormat = sourceFormat;
- mStateItem->sinkFormat = sinkFormat;
- mStateItem->factoryId = factoryId;
- }
-
- //XXX Almost all of this is copied and pasted from the ulaw<->alaw translator.
- //This should probably extracted into a base class...
- ~ResampleOperation()
- {
- mLogger(Debug) << "ResampleOperation destructor called";
-
- try
- {
- mAdapter->remove(mSourceProxy->ice_getIdentity());
- mAdapter->remove(mSinkProxy->ice_getIdentity());
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while trying to remove source and sink from object adapter";
- }
- }
-
- void setState()
- {
- if (mReplicationContext->isReplicating() == false)
- {
- return;
- }
-
- try
- {
- MediaOperationStateItemSeq seq;
- seq.push_back(mStateItem);
- mReplicationContext->getReplicator().tryOneWay()->setState(seq);
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
- }
- }
-
- void removeState()
- {
- if (mReplicationContext->isReplicating() == false)
- {
- return;
- }
-
- try
- {
- MediaOperationStateItemSeq seq;
- seq.push_back(mStateItem);
- mReplicationContext->getReplicator().tryOneWay()->removeStateForItems(seq);
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
- }
- }
-
- MediaOperationPrx activate(const std::string& id)
- {
- mProxy =
- MediaOperationPrx::uncheckedCast(mAdapter->add(this, mAdapter->getCommunicator()->stringToIdentity(id)));
- mSinkProxy =
- StreamSinkPrx::uncheckedCast(mAdapter->add(mSink, mAdapter->getCommunicator()->stringToIdentity(id + ".Sink")));
- mSourceProxy =
- StreamSourcePrx::uncheckedCast(mAdapter->add(mSource, mAdapter->getCommunicator()->stringToIdentity(id +".Source")));
-
- mStateItem->operationId = mProxy->ice_getIdentity().name;
-
- setState();
-
- return mProxy;
- }
-
- StreamSourcePrx getSource(const Ice::Current&)
- {
- return mSourceProxy;
- }
-
- StreamSinkPrx getSink(const Ice::Current&)
- {
- return mSinkProxy;
- }
-
- void destroy(const Ice::Current&)
+ : TranslatorOperation(
+ adapter,
+ logger,
+ sourceFormat,
+ sinkFormat,
+ factoryId,
+ replicationContext,
+ new ResamplerMediaOperationStateItem)
{
- try
- {
- mAdapter->remove(mProxy->ice_getIdentity());
- }
- catch (Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught attempting to remove media operation from adapter: " << ex.what();
- }
+ mSink->setTranslator(new Resampler(mSource, sinkFormat, sourceFormat, mLogger, cachingPool));
}
-
-private:
- Ice::ObjectAdapterPtr mAdapter;
- Logger mLogger;
- MediaOperationPrx mProxy;
- ResamplerMediaOperationStateItemPtr mStateItem;
- TranslatorSourcePtr mSource;
- StreamSourcePrx mSourceProxy;
- TranslatorSinkPtr mSink;
- StreamSinkPrx mSinkProxy;
- MediaOperationReplicationContextPtr mReplicationContext;
};
typedef IceUtil::Handle<ResampleOperation> ResampleOperationPtr;
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index b7f944e..13141ab 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -23,6 +23,7 @@
#include "TranslatorSource.h"
#include "Translator.h"
#include "TranslatorSink.h"
+#include "TranslatorOperation.h"
namespace AsteriskSCF
{
@@ -36,7 +37,7 @@ using namespace AsteriskSCF::Media::Formats::Audio::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
-class UlawAlawOperation : public MediaOperation
+class UlawAlawOperation : public TranslatorOperation
{
private:
class UlawAlawTranslator : public Translator
@@ -107,119 +108,17 @@ public:
const FormatPtr& sinkFormat,
const Ice::Identity& factoryId,
const MediaOperationReplicationContextPtr& replicationContext)
- : mAdapter(adapter),
- mLogger(logger),
- mStateItem(new UlawAlawMediaOperationStateItem),
- mSource(new TranslatorSource(mLogger, sourceFormat)),
- mSink(new TranslatorSink(mLogger, sinkFormat, new UlawAlawTranslator(mSource, sinkFormat, sourceFormat, mLogger))),
- mReplicationContext(replicationContext)
- {
- mStateItem->sourceFormat = sourceFormat;
- mStateItem->sinkFormat = sinkFormat;
- mStateItem->factoryId = factoryId;
- }
-
- ~UlawAlawOperation()
- {
- mLogger(Debug) << "UlawAlawOperation destructor called";
-
- try
- {
- mAdapter->remove(mSourceProxy->ice_getIdentity());
- mAdapter->remove(mSinkProxy->ice_getIdentity());
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while trying to remove source and sink from object adapter";
- }
- }
-
- void setState()
- {
- if (mReplicationContext->isReplicating() == false)
- {
- return;
- }
-
- try
- {
- MediaOperationStateItemSeq seq;
- seq.push_back(mStateItem);
- mReplicationContext->getReplicator().tryOneWay()->setState(seq);
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
- }
- }
-
- void removeState()
- {
- if (mReplicationContext->isReplicating() == false)
- {
- return;
- }
-
- try
- {
- MediaOperationStateItemSeq seq;
- seq.push_back(mStateItem);
- mReplicationContext->getReplicator().tryOneWay()->removeStateForItems(seq);
- }
- catch (const Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught while attempting to replicate state: " << ex.what();
- }
- }
-
- MediaOperationPrx activate(const std::string& id)
- {
- mProxy =
- MediaOperationPrx::uncheckedCast(mAdapter->add(this, mAdapter->getCommunicator()->stringToIdentity(id)));
- mSinkProxy =
- StreamSinkPrx::uncheckedCast(mAdapter->add(mSink, mAdapter->getCommunicator()->stringToIdentity(id + ".Sink")));
- mSourceProxy =
- StreamSourcePrx::uncheckedCast(mAdapter->add(mSource, mAdapter->getCommunicator()->stringToIdentity(id +".Source")));
-
- mStateItem->operationId = mProxy->ice_getIdentity().name;
-
- setState();
-
- return mProxy;
- }
-
- StreamSourcePrx getSource(const Ice::Current&)
- {
- return mSourceProxy;
- }
-
- StreamSinkPrx getSink(const Ice::Current&)
- {
- return mSinkProxy;
- }
-
- void destroy(const Ice::Current&)
+ : TranslatorOperation(
+ adapter,
+ logger,
+ sourceFormat,
+ sinkFormat,
+ factoryId,
+ replicationContext,
+ new UlawAlawMediaOperationStateItem)
{
- try
- {
- mAdapter->remove(mProxy->ice_getIdentity());
- }
- catch (Ice::Exception& ex)
- {
- mLogger(Error) << "Exception caught attempting to remove media operation from adapter: " << ex.what();
- }
+ mSink->setTranslator(new UlawAlawTranslator(mSource, sinkFormat, sourceFormat, mLogger));
}
-
-private:
- Ice::ObjectAdapterPtr mAdapter;
- Logger mLogger;
- MediaOperationPrx mProxy;
- UlawAlawMediaOperationStateItemPtr mStateItem;
- TranslatorSourcePtr mSource;
- StreamSourcePrx mSourceProxy;
- TranslatorSinkPtr mSink;
- StreamSinkPrx mSinkProxy;
- MediaOperationReplicationContextPtr mReplicationContext;
};
typedef IceUtil::Handle<UlawAlawOperation> UlawAlawOperationPtr;
commit 306b4e7333135cdbf119f4fafae4f18e1121a72f
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 30 14:47:07 2011 -0500
Create a common translator factory class and make the resampler and ulaw<->alaw translator use it.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 60673b9..4de238e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,18 +2,20 @@ include_directories(${logger_dir}/include)
include_directories(${astscf-ice-util-cpp_dir}/include)
astscf_component_init(MediaOperationsCore)
-astscf_component_add_files(MediaOperationsCore ulaw_alaw.h)
-astscf_component_add_files(MediaOperationsCore ulaw_alaw.cpp)
-astscf_component_add_files(MediaOperationsCore resample.h)
-astscf_component_add_files(MediaOperationsCore resample.cpp)
-astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.h)
-astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.cpp)
astscf_component_add_files(MediaOperationsCore Translator.cpp)
astscf_component_add_files(MediaOperationsCore Translator.h)
astscf_component_add_files(MediaOperationsCore TranslatorSink.cpp)
astscf_component_add_files(MediaOperationsCore TranslatorSink.h)
astscf_component_add_files(MediaOperationsCore TranslatorSource.cpp)
astscf_component_add_files(MediaOperationsCore TranslatorSource.h)
+astscf_component_add_files(MediaOperationsCore TranslatorOperationFactory.cpp)
+astscf_component_add_files(MediaOperationsCore TranslatorOperationFactory.h)
+astscf_component_add_files(MediaOperationsCore ulaw_alaw.h)
+astscf_component_add_files(MediaOperationsCore ulaw_alaw.cpp)
+astscf_component_add_files(MediaOperationsCore resample.h)
+astscf_component_add_files(MediaOperationsCore resample.cpp)
+astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.h)
+astscf_component_add_files(MediaOperationsCore MediaOperationFactoryImpl.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationsCore.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationStateReplicatorListener.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationReplicationContext.h)
diff --git a/src/TranslatorOperationFactory.cpp b/src/TranslatorOperationFactory.cpp
new file mode 100644
index 0000000..ba13657
--- /dev/null
+++ b/src/TranslatorOperationFactory.cpp
@@ -0,0 +1,137 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <IceUtil/UUID.h>
+
+#include "TranslatorOperationFactory.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::System::Logging;
+
+TranslatorOperationFactory::TranslatorOperationFactory(
+ const Ice::ObjectAdapterPtr& adapter,
+ const Logger& logger,
+ const MediaOperationReplicationContextPtr& replicationContext,
+ const std::string& name)
+ : MediaOperationFactoryImpl(adapter, logger, replicationContext, name)
+{
+ mLocatorParams->category = MediaOperationDiscoveryCategory;
+ mLocatorParams->service = MediaOperationDiscoveryTranslatorService;
+}
+
... 1931 lines suppressed ...
--
asterisk-scf/release/media_operations_core.git
More information about the asterisk-scf-commits
mailing list