[asterisk-scf-commits] asterisk-scf/integration/media_operations_core.git branch "resample" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 23 18:41:56 CDT 2011
branch "resample" has been created
at 3ba249204e625f7172c74bffab0748c736fe5d21 (commit)
- Log -----------------------------------------------------------------
commit 3ba249204e625f7172c74bffab0748c736fe5d21
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 23 18:42:20 2011 -0500
This gets the tests passing. It's not the most refined code imaginable
but hey, it works at this point. That's cool :)
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index f56286d..e78218e 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -53,8 +53,8 @@ typedef std::vector<std::pair<MediaOperationFactoryImplPtr, MediaOperationFactor
class MediaOperationsCompare : public ServiceLocatorParamsCompare
{
public:
- MediaOperationsCompare(const MediaOperationFactorySeq& factories)
- : mFactories(factories) { }
+ MediaOperationsCompare(const MediaOperationFactoryImplPtr& factory)
+ : mFactory(factory) { }
bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
{
@@ -69,36 +69,93 @@ public:
return false;
}
- for (MediaOperationFactorySeq::iterator seqIter = mFactories.begin();
- seqIter != mFactories.end(); ++seqIter)
+ MediaOperationServiceLocatorParamsPtr ourParams = mFactory->getLocatorParams();
+ for (MediaOperationAttributesSeq::iterator ourParamsIter = ourParams->attributes.begin();
+ ourParamsIter != ourParams->attributes.end(); ++ourParamsIter)
{
- MediaOperationServiceLocatorParamsPtr ourParams = seqIter->first->getLocatorParams();
- for (MediaOperationAttributesSeq::iterator ourParamsIter = ourParams->attributes.begin();
- ourParamsIter != ourParams->attributes.end(); ++ourParamsIter)
+ for (MediaOperationAttributesSeq::iterator theirParamsIter = toCompare->attributes.begin();
+ theirParamsIter != toCompare->attributes.end(); ++theirParamsIter)
{
- for (MediaOperationAttributesSeq::iterator theirParamsIter = toCompare->attributes.begin();
- theirParamsIter != toCompare->attributes.end(); ++theirParamsIter)
+ lg(Debug) << "Our input: " << ourParamsIter->inputFormat->name;
+ lg(Debug) << "Their input: " << theirParamsIter->inputFormat->name;
+ lg(Debug) << "Our output: " << ourParamsIter->outputFormat->name;
+ lg(Debug) << "Their output: " << theirParamsIter->outputFormat->name;
+ if (theirParamsIter->inputFormat->name == ourParamsIter->inputFormat->name &&
+ theirParamsIter->outputFormat->name == ourParamsIter->outputFormat->name)
{
- lg(Debug) << "Our input: " << ourParamsIter->inputFormat->name;
- lg(Debug) << "Their input: " << theirParamsIter->inputFormat->name;
- lg(Debug) << "Our output: " << ourParamsIter->outputFormat->name;
- lg(Debug) << "Their output: " << theirParamsIter->outputFormat->name;
- if (theirParamsIter->inputFormat->name == ourParamsIter->inputFormat->name &&
- theirParamsIter->outputFormat->name == ourParamsIter->outputFormat->name)
- {
- return true;
- }
+ return true;
}
}
}
return false;
}
private:
- MediaOperationFactorySeq mFactories;
+ MediaOperationFactoryImplPtr mFactory;
};
typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
+/**
+ * Wrapper class around pj_thread_desc.
+ */
+class ThreadDescWrapper
+{
+public:
+ /**
+ * pjthread thread description information, must persist for the life of the thread
+ */
+ pj_thread_desc mDesc;
+};
+
+/**
+ * Type definition used to create a smart pointer for the above.
+ */
+typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
+
+//XXX Seriously how many places is this repeated?
+/**
+ * Implementation of the Ice::ThreadNotification class.
+ */
+class pjlibHook : public Ice::ThreadNotification
+{
+public:
+ /**
+ * Implementation of the start function which is called when a thread starts.
+ */
+ void start()
+ {
+ ThreadDescWrapperPtr wrapper = ThreadDescWrapperPtr(new ThreadDescWrapper());
+ pj_thread_t *thread;
+ pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
+ {
+ boost::lock_guard<boost::mutex> lock(mLock);
+ pjThreads.insert(std::make_pair(thread, wrapper));
+ }
+ }
+
+ /**
+ * Implementation of the stop function which is called when a thread stops.
+ */
+ void stop()
+ {
+ if (pj_thread_is_registered())
+ {
+ boost::lock_guard<boost::mutex> lock(mLock);
+ pjThreads.erase(pj_thread_this());
+ }
+ }
+
+private:
+ /**
+ * A map containing thread lifetime persistent data.
+ */
+ std::map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
+ /**
+ * Mutex to protect the map
+ */
+ boost::mutex mLock;
+};
+
class MediaOperationsComponent : public AsteriskSCF::Component::Component
{
public:
@@ -178,13 +235,29 @@ private:
iter->second,
iter->first->getName(),
iter->first->getLocatorParams(),
- CompareGuid));
+ iter->first->getName()));
managePrimaryService(wrapper);
}
}
// Below are overrides of the base component class.
+
+ void onPreInitialize()
+ {
+ try
+ {
+ Ice::InitializationData id;
+ id.threadHook = new pjlibHook();
+ id.properties = getCommunicator()->getProperties();
+
+ setCommunicator(Ice::initialize(id));
+ }
+ catch (const std::exception& e)
+ {
+ lg(Critical) << "Unable to create communicator properly: " << e.what();
+ }
+ }
void createPrimaryServices()
{
@@ -205,10 +278,14 @@ private:
//of our custom comparator.
void onRegisterPrimaryServices()
{
- MediaOperationsComparePtr compare = new MediaOperationsCompare(mFactories);
- ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(getServiceAdapter()->addWithUUID(compare));
+ for (MediaOperationFactorySeq::const_iterator iter = mFactories.begin();
+ iter != mFactories.end(); ++iter)
+ {
+ MediaOperationsComparePtr compare = new MediaOperationsCompare(iter->first);
+ ServiceLocatorParamsComparePrx compareProxy = ServiceLocatorParamsComparePrx::uncheckedCast(getServiceAdapter()->addWithUUID(compare));
- getServiceLocatorManagement()->addCompare(CompareGuid, compareProxy);
+ getServiceLocatorManagement()->addCompare(iter->first->getName(), compareProxy);
+ }
}
void onUnregisterPrimaryServices()
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index ec4216c..5344ac9 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -249,9 +249,11 @@ struct GlobalIceFixture
Testbed.slin8 = new SignedLinear();
Testbed.slin8->name = SignedLinear8Name;
+ Testbed.slin8->sampleRate = 8000;
Testbed.slin16 = new SignedLinear();
Testbed.slin16->name = SignedLinear16Name;
+ Testbed.slin16->sampleRate = 16000;
Testbed.sampleAlawFrame = new Frame(Testbed.alaw, new ByteSeqPayload(Ice::ByteSeq(sampleAlaw, sampleAlaw + sizeof(sampleAlaw))));
Testbed.sampleAlawFrameSize = sizeof(sampleAlaw);
commit 248bf58e224c285c801d1509c9810625d8bf5079
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 23 17:04:17 2011 -0500
Add progress to resampling. I've realized there are some
errors I've made in my initial coding and so I'm switching
to master to fix them there.
diff --git a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
index 3b5d04e..e68a547 100644
--- a/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.ice
@@ -71,18 +71,32 @@ const string StateReplicatorDiscoveryCategory = "SipStateReplicator";
sequence<MediaOperationStateItem> MediaOperationStateItemSeq;
/**
- * State item for a ulaw<->alaw translator
+ * A common state item to be used by all translating media operations.
*/
-class UlawAlawMediaOperationStateItem extends MediaOperationStateItem
+class TranslatorMediaOperationStateItem extends MediaOperationStateItem
{
- /**
+ /**
* The format to use for the source of the media operation
*/
- AsteriskSCF::Media::V1::Format sourceFormat;
+ AsteriskSCF::Media::V1::AudioFormat sourceFormat;
/**
* The format to use for the sink of the media operation
*/
- AsteriskSCF::Media::V1::Format sinkFormat;
+ AsteriskSCF::Media::V1::AudioFormat sinkFormat;
+};
+
+/**
+ * State item for a ulaw<->alaw translator
+ */
+class UlawAlawMediaOperationStateItem extends TranslatorMediaOperationStateItem
+{
+};
+
+/**
+ * State item for a resampler
+ */
+class ResamplerMediaOperationStateItem extends TranslatorMediaOperationStateItem
+{
};
interface MediaOperationStateReplicatorListener
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fafe1f2..60673b9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,6 +4,8 @@ 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)
@@ -25,6 +27,7 @@ pjproject_link(MediaOperationsCore pjlib)
pjproject_link(MediaOperationsCore pjlib-util)
pjproject_link(MediaOperationsCore pjmedia)
pjproject_link(MediaOperationsCore pjnath)
+pjproject_link(MediaOperationsCore resample)
astscf_component_install(MediaOperationsCore)
astscf_component_init(MediaOperationStateReplicator)
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 11d244e..f56286d 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -24,6 +24,7 @@
#include "MediaOperationReplicationContext.h"
#include "MediaOperationFactoryImpl.h"
#include "ulaw_alaw.h"
+#include "resample.h"
using namespace AsteriskSCF::System::Logging;
@@ -128,6 +129,10 @@ private:
lg(Debug) << "Creating UlawAlawFactory";
createAndRegisterFactory(new UlawAlawFactory(getServiceAdapter(), lg,
boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext())));
+
+ lg(Debug) << "Creating Resampler";
+ createAndRegisterFactory(new ResampleFactory(getServiceAdapter(), lg,
+ boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext())));
}
void locateStateReplicator()
diff --git a/src/Translator.cpp b/src/Translator.cpp
index 3e12631..4fb069c 100644
--- a/src/Translator.cpp
+++ b/src/Translator.cpp
@@ -26,8 +26,8 @@ using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::System::Logging;
Translator::Translator(const TranslatorSourcePtr& source,
- const FormatPtr& inputFormat,
- const FormatPtr& outputFormat,
+ const AudioFormatPtr& inputFormat,
+ const AudioFormatPtr& outputFormat,
const Logger& logger)
: mSource(source),
mInputFormat(inputFormat),
diff --git a/src/Translator.h b/src/Translator.h
index 2884875..31dc1b0 100644
--- a/src/Translator.h
+++ b/src/Translator.h
@@ -31,8 +31,8 @@ class Translator : public IceUtil::Shared
{
public:
Translator(const TranslatorSourcePtr& source,
- const AsteriskSCF::Media::V1::FormatPtr& inputFormat,
- const AsteriskSCF::Media::V1::FormatPtr& outputFormat,
+ const AsteriskSCF::Media::V1::AudioFormatPtr& inputFormat,
+ const AsteriskSCF::Media::V1::AudioFormatPtr& outputFormat,
const AsteriskSCF::System::Logging::Logger& logger);
virtual ~Translator();
@@ -55,8 +55,8 @@ public:
protected:
TranslatorSourcePtr mSource;
- AsteriskSCF::Media::V1::FormatPtr mInputFormat;
- AsteriskSCF::Media::V1::FormatPtr mOutputFormat;
+ AsteriskSCF::Media::V1::AudioFormatPtr mInputFormat;
+ AsteriskSCF::Media::V1::AudioFormatPtr mOutputFormat;
AsteriskSCF::System::Logging::Logger mLogger;
};
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index b27bf7a..3286864 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -43,8 +43,8 @@ private:
{
public:
UlawAlawTranslator(const TranslatorSourcePtr source,
- const FormatPtr& inputFormat,
- const FormatPtr& outputFormat,
+ const AudioFormatPtr& inputFormat,
+ const AudioFormatPtr& outputFormat,
const Logger& logger)
: Translator(source, inputFormat, outputFormat, logger)
{
@@ -73,18 +73,29 @@ private:
FramePtr outFrame;
Ice::ByteSeq outPayload;
- outPayload.resize(inFrame->payload.size());
+ //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)
+ {
+ mLogger(Error) << "The incoming frame's payload is not a byte sequence.";
+ throw UnsupportedMediaFormatException();
+ }
+
if (inFrame->mediaFormat->name == G711uLAWName)
{
- std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::ulaw2alaw), this));
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload), std::bind1st(std::mem_fun(&UlawAlawTranslator::ulaw2alaw), this));
}
else
{
- std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::alaw2ulaw), this));
+ std::transform(inPayload->payload.begin(), inPayload->payload.end(), std::back_inserter(outPayload), std::bind1st(std::mem_fun(&UlawAlawTranslator::alaw2ulaw), this));
}
- outFrame = new Frame(mOutputFormat, outPayload);
+ outFrame = new Frame(mOutputFormat, new ByteSeqPayload(outPayload));
return outFrame;
}
};
@@ -92,8 +103,8 @@ private:
public:
UlawAlawOperation(const Ice::ObjectAdapterPtr& adapter,
const Logger& logger,
- const FormatPtr& sourceFormat,
- const FormatPtr& sinkFormat,
+ const AudioFormatPtr& sourceFormat,
+ const AudioFormatPtr& sinkFormat,
const Ice::Identity& factoryId,
const MediaOperationReplicationContextPtr& replicationContext)
: mAdapter(adapter),
@@ -322,8 +333,8 @@ MediaOperationPrx UlawAlawFactory::createMediaOperation(
}
MediaOperationPrx UlawAlawFactory::createMediaOperation(
- const FormatPtr& sourceFormat,
- const FormatPtr& sinkFormat,
+ const AudioFormatPtr& sourceFormat,
+ const AudioFormatPtr& sinkFormat,
const std::string& operationId)
{
UlawAlawOperationPtr operation(
diff --git a/src/ulaw_alaw.h b/src/ulaw_alaw.h
index 4d4c56c..abcea86 100644
--- a/src/ulaw_alaw.h
+++ b/src/ulaw_alaw.h
@@ -32,8 +32,8 @@ public:
const MediaOperationReplicationContextPtr& replicationContext);
void replicateState(const AsteriskSCF::Media::V1::MediaOperationPrx& proxy,
- const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
- const AsteriskSCF::Media::V1::FormatPtr& sinkFormat);
+ const AsteriskSCF::Media::V1::AudioFormatPtr& sourceFormat,
+ const AsteriskSCF::Media::V1::AudioFormatPtr& sinkFormat);
AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
const AsteriskSCF::Media::V1::StreamSourcePrx& source,
@@ -41,8 +41,8 @@ public:
const Ice::Current&);
AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
- const AsteriskSCF::Media::V1::FormatPtr& sourceFormat,
- const AsteriskSCF::Media::V1::FormatPtr& sinkFormat,
+ const AsteriskSCF::Media::V1::AudioFormatPtr& sourceFormat,
+ const AsteriskSCF::Media::V1::AudioFormatPtr& sinkFormat,
const std::string& operationId);
};
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index 0b5371d..ec4216c 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -56,6 +56,10 @@ public:
FormatPtr alaw;
+ AudioFormatPtr slin8;
+
+ AudioFormatPtr slin16;
+
TestStreamSinkPtr ulawSink;
StreamSinkPrx ulawSinkProxy;
@@ -64,6 +68,14 @@ public:
StreamSinkPrx alawSinkProxy;
+ TestStreamSinkPtr slin8Sink;
+
+ StreamSinkPrx slin8SinkProxy;
+
+ TestStreamSinkPtr slin16Sink;
+
+ StreamSinkPrx slin16SinkProxy;
+
TestStreamSourcePtr alawSource;
StreamSourcePrx alawSourceProxy;
@@ -72,9 +84,25 @@ public:
StreamSourcePrx ulawSourceProxy;
+ TestStreamSourcePtr slin8Source;
+
+ StreamSourcePrx slin8SourceProxy;
+
+ TestStreamSourcePtr slin16Source;
+
+ StreamSourcePrx slin16SourceProxy;
+
FramePtr sampleAlawFrame;
+ size_t sampleAlawFrameSize;
+
FramePtr sampleUlawFrame;
+
+ size_t sampleUlawFrameSize;
+
+ FramePtr sampleSlin8Frame;
+
+ size_t sampleSlin8FrameSize;
};
static SharedTestData Testbed;
@@ -108,6 +136,21 @@ static uint8_t sampleUlaw[] = {
0x90, 0xc0, 0xc3, 0xc6, 0xc9, 0xcc, 0xcf, 0xd2,
};
+//Generated by combining 8-bit samples from sampleUlaw
+//into 16-bit samples.
+static uint16_t sampleSlin8[] = {
+ 0x0003, 0x0609, 0x0c0f, 0x1215,
+ 0x1018, 0x1b1e, 0x2124, 0x272a,
+ 0x202d, 0x3033, 0x3639, 0x3c3f,
+ 0x3042, 0x4548, 0x4b4e, 0x5154,
+ 0x4057, 0x5a5d, 0x6063, 0x6669,
+ 0x506c, 0x6f72, 0x7578, 0x7b7e,
+ 0x6081, 0x8487, 0x8a8d, 0x9093,
+ 0x7096, 0x999c, 0x9fa2, 0xa5a8,
+ 0x80ab, 0xaeb1, 0xb4b7, 0xbabd,
+ 0x90c0, 0xc3c6, 0xc9cc, 0xcfd2,
+};
+
/**
* Wrapper class around pj_thread_desc.
* (copied from PJSipManager.h in the sip repo)
@@ -204,9 +247,21 @@ struct GlobalIceFixture
Testbed.alaw = new G711aLAW();
Testbed.alaw->name = G711aLAWName;
+ Testbed.slin8 = new SignedLinear();
+ Testbed.slin8->name = SignedLinear8Name;
+
+ Testbed.slin16 = new SignedLinear();
+ Testbed.slin16->name = SignedLinear16Name;
+
+ Testbed.sampleAlawFrame = new Frame(Testbed.alaw, new ByteSeqPayload(Ice::ByteSeq(sampleAlaw, sampleAlaw + sizeof(sampleAlaw))));
+ Testbed.sampleAlawFrameSize = sizeof(sampleAlaw);
+
+ Testbed.sampleUlawFrame = new Frame(Testbed.ulaw, new ByteSeqPayload(Ice::ByteSeq(sampleUlaw, sampleUlaw + sizeof(sampleUlaw))));
+ Testbed.sampleUlawFrameSize = sizeof(sampleUlaw);
- Testbed.sampleAlawFrame = new Frame(Testbed.alaw, Ice::ByteSeq(sampleAlaw, sampleAlaw + sizeof(sampleAlaw)));
- Testbed.sampleUlawFrame = new Frame(Testbed.ulaw, Ice::ByteSeq(sampleUlaw, sampleUlaw + sizeof(sampleUlaw)));
+ ShortSeqPayloadPtr slin8Payload(new ShortSeqPayload(Ice::ShortSeq(sampleSlin8, sampleSlin8 + (sizeof(sampleSlin8) / 2))));
+ Testbed.sampleSlin8Frame = new Frame(Testbed.slin8, slin8Payload);
+ Testbed.sampleSlin8FrameSize = slin8Payload->payload.size();
}
catch (const Ice::Exception& ex)
{
@@ -252,6 +307,18 @@ public:
Testbed.alawSource = new TestStreamSource(Testbed.alaw);
Testbed.alawSourceProxy = StreamSourcePrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.alawSource));
+
+ Testbed.slin8Source = new TestStreamSource(Testbed.slin8);
+ Testbed.slin8SourceProxy = StreamSourcePrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin8Source));
+
+ Testbed.slin16Source = new TestStreamSource(Testbed.slin16);
+ Testbed.slin16SourceProxy = StreamSourcePrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin16Source));
+
+ Testbed.slin8Sink = new TestStreamSink(Testbed.slin8);
+ Testbed.slin8SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin8Sink));
+
+ Testbed.slin16Sink = new TestStreamSink(Testbed.slin16);
+ Testbed.slin16SinkProxy = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(Testbed.slin16Sink));
}
~PerTestFixture()
{
@@ -386,9 +453,12 @@ BOOST_FIXTURE_TEST_CASE(translateAlawToUlaw, PerTestFixture)
//Each frame written by the translator should be ulaw
BOOST_CHECK(G711uLAWPtr::dynamicCast((*iter)->mediaFormat) != 0);
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_CHECK(payload != 0);
//Each frame written by the translator should be the
//same size as the frame read in.
- BOOST_CHECK((*iter)->payload.size() == Testbed.sampleAlawFrame->payload.size());
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleAlawFrameSize);
}
alaw2ulawTranslator->destroy();
@@ -443,10 +513,70 @@ BOOST_FIXTURE_TEST_CASE(translateUlawToAlaw, PerTestFixture)
//Each frame written by the translator should be ulaw
BOOST_CHECK(G711aLAWPtr::dynamicCast((*iter)->mediaFormat) != 0);
+ ByteSeqPayloadPtr payload = ByteSeqPayloadPtr::dynamicCast((*iter)->payload);
+
+ BOOST_CHECK(payload != 0);
+
//Each frame written by the translator should be the
//same size as the frame read in.
- BOOST_CHECK((*iter)->payload.size() == Testbed.sampleUlawFrame->payload.size());
+ BOOST_CHECK(payload->payload.size() == Testbed.sampleUlawFrameSize);
}
ulaw2alawTranslator->destroy();
}
+
+BOOST_FIXTURE_TEST_CASE(resample8To16, 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;
+ Testbed.slin16->frameSize = Testbed.slin8->frameSize * 2;
+
+ MediaOperationServiceLocatorParamsPtr eightToSixteenParams = createLocatorParams(Testbed.slin8, Testbed.slin16);
+
+ MediaOperationFactoryPrx eightToSixteenFactory =
+ MediaOperationFactoryPrx::checkedCast(Testbed.locator->locate(eightToSixteenParams));
+
+ MediaOperationPrx eightToSixteenResampler =
+ eightToSixteenFactory->createMediaOperation(Testbed.slin8SourceProxy, Testbed.slin16SinkProxy);
+
+ StreamSinkPrx resampleSink = eightToSixteenResampler->getSink();
+ StreamSourcePrx resampleSource = eightToSixteenResampler->getSource();
+
+ Testbed.slin8SourceProxy->addSink(resampleSink);
+ Testbed.slin16SinkProxy->setSource(resampleSource);
+
+ resampleSource->addSink(Testbed.slin16SinkProxy);
+ resampleSink->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 resample slin8 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_CHECK(payload != 0);
+
+ BOOST_CHECK((int) payload->payload.size() == Testbed.slin16->frameSize);
+ }
+}
commit 58584bca51cd9a15f837713e8365b5010478f1f2
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 14:52:35 2011 -0500
Set Ice.Warn.UnknownProperties=0
diff --git a/config/test_component.config b/config/test_component.config
index f2ad55e..e3ec775 100644
--- a/config/test_component.config
+++ b/config/test_component.config
@@ -1,4 +1,5 @@
IceBox.InheritProperties=1
+Ice.Warn.UnknownProperties=0
IceBox.InstanceName=IceBox
IceBox.ServiceManager.Endpoints=tcp -p 10007
commit 0d962c2042dbdfec6639bf80581dd29a4531e3cc
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 14:51:19 2011 -0500
Add the test configuration file.
diff --git a/config/test_component.config b/config/test_component.config
new file mode 100644
index 0000000..f2ad55e
--- /dev/null
+++ b/config/test_component.config
@@ -0,0 +1,69 @@
+IceBox.InheritProperties=1
+
+IceBox.InstanceName=IceBox
+IceBox.ServiceManager.Endpoints=tcp -p 10007
+
+IceBox.Service.MediaOperationsCore=MediaOperationsCore:create
+IceBox.Service.ServiceDiscovery=service_locator:create
+
+IceBox.Service.MediaOperationsCoreTest=MediaOperationsCoreTest:create --log_level=all
+
+IceBox.LoadOrder=ServiceDiscovery,MediaOperationsCore,MediaOperationsCoreTest
+
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4422
+LocatorService.Proxy=LocatorService:tcp -p 4411
+
+MediaOperationsCore.Endpoints=default
+
+MediaOperationsCore.Backplane.Endpoints=default
+
+MediaOperationsCore.Standalone=true
+
+MediaOperationsCore.ComponentTest=false
+
+MediaOperationsCore.ServiceName=MediaOperationsCoreService
+
+TopicManager.Proxy=AsteriskSCFIceStorm/TopicManager:tcp -p 10000
+
+##########################################
+# Service Locator properties
+
+AsteriskSCFIceStorm.InstanceName=AsteriskSCFIceStorm
+#
+# This property defines the endpoints on which the IceStorm
+# TopicManager listens.
+#
+AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
+
+#
+# This property defines the endpoints on which the topic
+# publisher objects listen. If you want to federate
+# IceStorm instances this must run on a fixed port (or use
+# IceGrid).
+#
+AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
+
+#
+# TopicManager Tracing
+#
+# 0 = no tracing
+# 1 = trace topic creation, subscription, unsubscription
+# 2 = like 1, but with more detailed subscription information
+#
+AsteriskSCFIceStorm.Trace.TopicManager=2
+AsteriskSCFIceStorm.Transient=1
+
+#
+AsteriskSCFIceStorm.Flush.Timeout=2000
+# This is a configuration file used in conjunction with the service locator test driver
+
+# Test endpoints for the service locator management adapter
+ServiceLocatorManagementAdapter.Endpoints=tcp -p 4422
+
+# Test endpoints for the service locator adapter
+ServiceLocatorAdapter.Endpoints=tcp -p 4411
+ServiceLocatorLocalAdapter.Endpoints=tcp -p 4412
+
+# Logger configuration
+LoggerAdapter.Endpoints=default
+AsteriskSCF.Logging.logger.AsteriskSCF=Debug
commit 27bffa7e258ac6161f0b28dd82575f3f0c287679
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 13:38:55 2011 -0500
Ok, test succeeded.
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index cfbbd34..b27bf7a 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -27,7 +27,7 @@
namespace AsteriskSCF
{
- namespace MediaOperationsCore
+namespace MediaOperationsCore
{
using namespace AsteriskSCF::Media::V1;
commit e474f2f4089b2c2b4a071d8e0ba565ac513ce707
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 13:38:39 2011 -0500
just a test.
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index b27bf7a..cfbbd34 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -27,7 +27,7 @@
namespace AsteriskSCF
{
-namespace MediaOperationsCore
+ namespace MediaOperationsCore
{
using namespace AsteriskSCF::Media::V1;
commit 6a344b3b59137bd15ec4bd60dcfb631a6f8e020b
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 11:46:52 2011 -0500
Add some generic translator stuff to make it easier to add new ones later.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index acdcd12..fafe1f2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,12 @@ astscf_component_add_files(MediaOperationsCore ulaw_alaw.h)
astscf_component_add_files(MediaOperationsCore ulaw_alaw.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 MediaOperationsCore.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationStateReplicatorListener.cpp)
astscf_component_add_files(MediaOperationsCore MediaOperationReplicationContext.h)
diff --git a/src/Translator.cpp b/src/Translator.cpp
new file mode 100644
index 0000000..3e12631
--- /dev/null
+++ b/src/Translator.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "Translator.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::System::Logging;
+
+Translator::Translator(const TranslatorSourcePtr& source,
+ const FormatPtr& inputFormat,
+ const FormatPtr& outputFormat,
+ const Logger& logger)
+ : mSource(source),
+ mInputFormat(inputFormat),
+ mOutputFormat(outputFormat),
+ mLogger(logger)
+{
+}
+
+Translator::~Translator()
+{
+}
+
+void Translator::translateFrames(const FrameSeq& frames)
+{
+ FrameSeq translated;
+ translated.resize(frames.size());
+ std::transform(frames.begin(), frames.end(), translated.begin(), std::bind1st(std::mem_fun(&Translator::translate), this));
+ mSource->distributeToSinks(translated);
+}
+
+}
+}
diff --git a/src/Translator.h b/src/Translator.h
new file mode 100644
index 0000000..2884875
--- /dev/null
+++ b/src/Translator.h
@@ -0,0 +1,66 @@
+/*
+ * 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/MediaIf.h>
+#include <AsteriskSCF/logger.h>
+
+#include "TranslatorSource.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class Translator : public IceUtil::Shared
+{
+public:
+ Translator(const TranslatorSourcePtr& source,
+ const AsteriskSCF::Media::V1::FormatPtr& inputFormat,
+ const AsteriskSCF::Media::V1::FormatPtr& outputFormat,
+ const AsteriskSCF::System::Logging::Logger& logger);
+
+ virtual ~Translator();
+
+ /**
+ * Translate each frame from the input format into the
+ * output format.
+ *
+ * Note that implementors of this function should perform
+ * a check to be certain that the format of the frame
+ * being translated is what is expected for this translator
+ */
+ virtual AsteriskSCF::Media::V1::FramePtr translate(const AsteriskSCF::Media::V1::FramePtr inFrame) = 0;
+
+ /**
+ * Feeds each of the frames in the
+ * sequence into the translate() function
+ */
+ void translateFrames(const AsteriskSCF::Media::V1::FrameSeq& frames);
+
+protected:
+ TranslatorSourcePtr mSource;
+ AsteriskSCF::Media::V1::FormatPtr mInputFormat;
+ AsteriskSCF::Media::V1::FormatPtr mOutputFormat;
+ AsteriskSCF::System::Logging::Logger mLogger;
+};
+
+typedef IceUtil::Handle<Translator> TranslatorPtr;
+
+}
+}
diff --git a/src/TranslatorSink.cpp b/src/TranslatorSink.cpp
new file mode 100644
index 0000000..25bf231
--- /dev/null
+++ b/src/TranslatorSink.cpp
@@ -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.
+ */
+
+#include <IceUtil/UUID.h>
+
+#include "TranslatorSink.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::System::Logging;
+
+TranslatorSink::TranslatorSink(const Logger& logger,
+ const FormatPtr& supportedFormat,
+ const TranslatorPtr& translator)
+ : mLogger(logger),
+ mId(IceUtil::generateUUID()),
+ mTranslator(translator)
+{
+ mSupportedFormats.push_back(supportedFormat);
+}
+
+TranslatorSink::~TranslatorSink()
+{
+ mLogger(Debug) << "TranslatorSink destructor called";
+}
+
+void TranslatorSink::write(const FrameSeq& frames, const Ice::Current&)
+{
+ mTranslator->translateFrames(frames);
+}
+
+void TranslatorSink::setSource(const StreamSourcePrx& source, const Ice::Current&)
+{
+ mSource = source;
+}
+
+StreamSourcePrx TranslatorSink::getSource(const Ice::Current&)
+{
+ return mSource;
+}
+
+FormatSeq TranslatorSink::getFormats(const Ice::Current&)
+{
+ return mSupportedFormats;
+}
+
+std::string TranslatorSink::getId(const Ice::Current&)
+{
+ return mId;
+}
+
+}
+}
diff --git a/src/TranslatorSink.h b/src/TranslatorSink.h
new file mode 100644
index 0000000..fa5bee5
--- /dev/null
+++ b/src/TranslatorSink.h
@@ -0,0 +1,60 @@
+/*
+ * 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/MediaIf.h>
+#include <AsteriskSCF/logger.h>
+
+#include "Translator.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class TranslatorSink : public AsteriskSCF::Media::V1::StreamSink
+{
+public:
+ TranslatorSink(const AsteriskSCF::System::Logging::Logger& logger,
+ const AsteriskSCF::Media::V1::FormatPtr& supportedFormat,
+ const TranslatorPtr& translator);
+
+ ~TranslatorSink();
+
+ void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&);
+
+ void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&);
+
+ AsteriskSCF::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
+
+ AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&);
+
+ std::string getId(const Ice::Current&);
+
+private:
+ AsteriskSCF::System::Logging::Logger mLogger;
+ AsteriskSCF::Media::V1::FormatSeq mSupportedFormats;
+ AsteriskSCF::Media::V1::StreamSourcePrx mSource;
+ std::string mId;
+ TranslatorPtr mTranslator;
+};
+
+typedef IceUtil::Handle<TranslatorSink> TranslatorSinkPtr;
+
+}
+}
diff --git a/src/TranslatorSource.cpp b/src/TranslatorSource.cpp
new file mode 100644
index 0000000..b24cc68
--- /dev/null
+++ b/src/TranslatorSource.cpp
@@ -0,0 +1,101 @@
+/*
+ * 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 "TranslatorSource.h"
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::System::Logging;
+
+TranslatorSource::TranslatorSource(const Logger& logger,
+ const FormatPtr& format)
+ : mLogger(logger),
+ mId(IceUtil::generateUUID())
+{
+ mSupportedFormats.push_back(format);
+}
+
+TranslatorSource::~TranslatorSource()
+{
+ mLogger(Debug) << "TranslatorSource destructor called";
+}
+
+void TranslatorSource::addSink(const StreamSinkPrx& sink, const Ice::Current&)
+{
+ if (std::find(mSinks.begin(), mSinks.end(), sink) == mSinks.end())
+ {
+ mSinks.push_back(sink);
+ }
+}
+
+void TranslatorSource::removeSink(const StreamSinkPrx& sink, const Ice::Current&)
+{
+ mSinks.erase(std::remove(mSinks.begin(), mSinks.end(), sink), mSinks.end());
+}
+
+StreamSinkSeq TranslatorSource::getSinks(const Ice::Current&)
+{
+ return mSinks;
+}
+
+FormatSeq TranslatorSource::getFormats(const Ice::Current&)
+{
+ return mSupportedFormats;
+}
+
+std::string TranslatorSource::getId(const Ice::Current&)
+{
+ return mId;
+}
+
+//XXX
+//I interpreted this to essentially be a check to make sure that
+//the format we actually are using matches what is expected.
+void TranslatorSource::requestFormat(const FormatPtr& format, const Ice::Current&)
+{
+ FormatPtr supportedFormat = mSupportedFormats.front();
+
+ if (supportedFormat->name != format->name)
+ {
+ mLogger(Error) << "Format requested is not the one supported by this source";
+ throw MediaFormatSwitchException();
+ }
+}
+
+void TranslatorSource::distributeToSinks(const FrameSeq& translatedFrames)
+{
+ for (StreamSinkSeq::iterator iter = mSinks.begin();
+ iter != mSinks.end(); ++iter)
+ {
+ try
+ {
+ (*iter)->write(translatedFrames);
+ }
+ catch (Ice::Exception& ex)
+ {
+ mLogger(Error) << "Error attempting to write frames to a sink: " << ex.what();
+ }
+ }
+}
+
+}
+}
diff --git a/src/TranslatorSource.h b/src/TranslatorSource.h
new file mode 100644
index 0000000..f17515a
--- /dev/null
+++ b/src/TranslatorSource.h
@@ -0,0 +1,60 @@
+/*
+ * 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/MediaIf.h>
+#include <AsteriskSCF/logger.h>
+
+namespace AsteriskSCF
+{
+
+namespace MediaOperationsCore
+{
+
+class TranslatorSource : public AsteriskSCF::Media::V1::StreamSource
+{
+public:
+ TranslatorSource(const AsteriskSCF::System::Logging::Logger& logger,
+ const AsteriskSCF::Media::V1::FormatPtr& format);
+
+ ~TranslatorSource();
+
+ void addSink(const AsteriskSCF::Media::V1::StreamSinkPrx& sink, const Ice::Current&);
+
+ void removeSink(const AsteriskSCF::Media::V1::StreamSinkPrx& sink, const Ice::Current&);
+
+ AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
+
+ AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&);
+
+ std::string getId(const Ice::Current&);
+
+ void requestFormat(const AsteriskSCF::Media::V1::FormatPtr& format, const Ice::Current&);
+
+ void distributeToSinks(const AsteriskSCF::Media::V1::FrameSeq& translatedFrames);
+
+private:
+ AsteriskSCF::System::Logging::Logger mLogger;
+ AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
+ AsteriskSCF::Media::V1::FormatSeq mSupportedFormats;
+ std::string mId;
+};
+
+typedef IceUtil::Handle<TranslatorSource> TranslatorSourcePtr;
+
+}
+}
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 708fee1..b27bf7a 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -14,13 +14,16 @@
* at the top of the source tree.
*/
-#include "ulaw_alaw.h"
-
#include <AsteriskSCF/Media/Formats/AudioFormats.h>
#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
#include <IceUtil/UUID.h>
#include <pjmedia.h>
+#include "ulaw_alaw.h"
+#include "TranslatorSource.h"
+#include "Translator.h"
+#include "TranslatorSink.h"
+
namespace AsteriskSCF
{
@@ -33,107 +36,17 @@ using namespace AsteriskSCF::Media::Formats::Audio::V1;
using namespace AsteriskSCF::System::Logging;
using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
-class UlawAlawOperation;
-typedef IceUtil::Handle<UlawAlawOperation> UlawAlawOperationPtr;
-
class UlawAlawOperation : public MediaOperation
{
private:
-
- class UlawAlawSource : public StreamSource
+ class UlawAlawTranslator : public Translator
{
public:
-
- UlawAlawSource(const Logger& logger,
- const FormatPtr& format)
- : mLogger(logger),
- mId(IceUtil::generateUUID())
- {
- mSupportedFormats.push_back(format);
- }
-
- ~UlawAlawSource()
- {
- mLogger(Debug) << "UlawAlawSource destructor called";
- }
-
- void addSink(const StreamSinkPrx& sink, const Ice::Current&)
- {
- if (std::find(mSinks.begin(), mSinks.end(), sink) == mSinks.end())
- {
- mSinks.push_back(sink);
- }
- }
-
- void removeSink(const StreamSinkPrx& sink, const Ice::Current&)
- {
- mSinks.erase(std::remove(mSinks.begin(), mSinks.end(), sink), mSinks.end());
- }
-
- StreamSinkSeq getSinks(const Ice::Current&)
- {
- return mSinks;
- }
-
- FormatSeq getFormats(const Ice::Current&)
- {
- return mSupportedFormats;
- }
-
- std::string getId(const Ice::Current&)
- {
- return mId;
- }
-
- //XXX
- //I interpreted this to essentially be a check to make sure that
- //the format we actually are using matches what is expected.
- void requestFormat(const FormatPtr& format, const Ice::Current&)
- {
- FormatPtr supportedFormat = mSupportedFormats.front();
-
- if (supportedFormat->name != format->name)
- {
- mLogger(Error) << "Format requested is not the one supported by this source";
- throw MediaFormatSwitchException();
- }
- }
-
- void distributeToSinks(const FrameSeq& translatedFrames)
- {
- for (StreamSinkSeq::iterator iter = mSinks.begin();
- iter != mSinks.end(); ++iter)
- {
- try
- {
- (*iter)->write(translatedFrames);
- }
- catch (Ice::Exception& ex)
- {
- mLogger(Error) << "Error attempting to write frames to a sink: " << ex.what();
- }
- }
- }
-
- Logger mLogger;
- StreamSinkSeq mSinks;
- FormatSeq mSupportedFormats;
- std::string mId;
- };
-
- typedef IceUtil::Handle<UlawAlawSource> UlawAlawSourcePtr;
-
- class UlawAlawTranslator : public IceUtil::Shared
- {
- public:
- UlawAlawTranslator(const UlawAlawSourcePtr source,
+ UlawAlawTranslator(const TranslatorSourcePtr source,
const FormatPtr& inputFormat,
const FormatPtr& outputFormat,
const Logger& logger)
- : mSource(source),
- mInputFormat(inputFormat),
- mOutputFormat(outputFormat),
- mLogger(logger)
+ : Translator(source, inputFormat, outputFormat, logger)
{
}
@@ -147,6 +60,9 @@ private:
return pjmedia_alaw2ulaw(alaw);
}
+ /**
+ * Override of Translator's translate function.
+ */
FramePtr translate(const FramePtr inFrame)
{
if (inFrame->mediaFormat->name != mInputFormat->name)
@@ -171,76 +87,8 @@ private:
outFrame = new Frame(mOutputFormat, outPayload);
return outFrame;
}
-
- void translateFrames(const FrameSeq& frames)
- {
- FrameSeq translated;
- translated.resize(frames.size());
- std::transform(frames.begin(), frames.end(), translated.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::translate), this));
- mSource->distributeToSinks(translated);
- }
-
- private:
- UlawAlawSourcePtr mSource;
- FormatPtr mInputFormat;
- FormatPtr mOutputFormat;
- Logger mLogger;
};
- typedef IceUtil::Handle<UlawAlawTranslator> UlawAlawTranslatorPtr;
-
- class UlawAlawSink : public StreamSink
- {
- public:
- UlawAlawSink(const Logger& logger,
- const FormatPtr& supportedFormat,
- const UlawAlawTranslatorPtr& translator)
- : mLogger(logger),
- mId(IceUtil::generateUUID()),
- mTranslator(translator)
- {
- mSupportedFormats.push_back(supportedFormat);
- }
-
- ~UlawAlawSink()
- {
- mLogger(Debug) << "UlawAlawSink destructor called";
- }
-
- void write(const FrameSeq& frames, const Ice::Current&)
- {
- mTranslator->translateFrames(frames);
- }
-
- void setSource(const StreamSourcePrx& source, const Ice::Current&)
- {
- mSource = source;
- }
-
- StreamSourcePrx getSource(const Ice::Current&)
- {
- return mSource;
- }
-
- FormatSeq getFormats(const Ice::Current&)
- {
- return mSupportedFormats;
- }
-
- std::string getId(const Ice::Current&)
- {
- return mId;
- }
-
- Logger mLogger;
- FormatSeq mSupportedFormats;
- StreamSourcePrx mSource;
- std::string mId;
- UlawAlawTranslatorPtr mTranslator;
- };
-
- typedef IceUtil::Handle<UlawAlawSink> UlawAlawSinkPtr;
-
public:
UlawAlawOperation(const Ice::ObjectAdapterPtr& adapter,
const Logger& logger,
@@ -251,8 +99,8 @@ public:
: mAdapter(adapter),
mLogger(logger),
mStateItem(new UlawAlawMediaOperationStateItem),
- mSource(new UlawAlawSource(mLogger, sourceFormat)),
- mSink(new UlawAlawSink(mLogger, sinkFormat, new UlawAlawTranslator(mSource, sinkFormat, sourceFormat, mLogger))),
+ mSource(new TranslatorSource(mLogger, sourceFormat)),
+ mSink(new TranslatorSink(mLogger, sinkFormat, new UlawAlawTranslator(mSource, sinkFormat, sourceFormat, mLogger))),
mReplicationContext(replicationContext)
{
mStateItem->sourceFormat = sourceFormat;
@@ -356,13 +204,15 @@ private:
Logger mLogger;
MediaOperationPrx mProxy;
UlawAlawMediaOperationStateItemPtr mStateItem;
- UlawAlawSourcePtr mSource;
+ TranslatorSourcePtr mSource;
StreamSourcePrx mSourceProxy;
- UlawAlawSinkPtr mSink;
+ TranslatorSinkPtr mSink;
StreamSinkPrx mSinkProxy;
MediaOperationReplicationContextPtr mReplicationContext;
};
+typedef IceUtil::Handle<UlawAlawOperation> UlawAlawOperationPtr;
+
UlawAlawFactory::UlawAlawFactory(const Ice::ObjectAdapterPtr& adapter,
const Logger& logger,
const MediaOperationReplicationContextPtr& replicationContext)
@@ -443,7 +293,6 @@ MediaOperationPrx UlawAlawFactory::createMediaOperation(
}
}
- UlawAlawOperationPtr operation;
if (sourceUlaw && sinkAlaw)
{
//Their source is ulaw and their sink is alaw.
commit 181a81f9dbbcaeeb83b0f11d474db22ee3893287
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 10:43:15 2011 -0500
Resolve a circular reference.
diff --git a/src/MediaOperationStateReplicatorListener.cpp b/src/MediaOperationStateReplicatorListener.cpp
index 66acaca..7cfb0f0 100644
--- a/src/MediaOperationStateReplicatorListener.cpp
+++ b/src/MediaOperationStateReplicatorListener.cpp
@@ -49,8 +49,6 @@ void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
private:
void visitUlawAlawMediaOperationStateItem(const UlawAlawMediaOperationStateItemPtr& ulawAlaw)
{
- mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId + ".Source"));
- mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId + ".Sink"));
mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId));
}
Ice::ObjectAdapterPtr mAdapter;
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 6d80960..708fee1 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -51,6 +51,11 @@ private:
{
mSupportedFormats.push_back(format);
}
+
+ ~UlawAlawSource()
+ {
+ mLogger(Debug) << "UlawAlawSource destructor called";
+ }
void addSink(const StreamSinkPrx& sink, const Ice::Current&)
{
@@ -118,12 +123,78 @@ private:
typedef IceUtil::Handle<UlawAlawSource> UlawAlawSourcePtr;
+ class UlawAlawTranslator : public IceUtil::Shared
+ {
+ public:
+ UlawAlawTranslator(const UlawAlawSourcePtr source,
+ const FormatPtr& inputFormat,
+ const FormatPtr& outputFormat,
+ const Logger& logger)
+ : mSource(source),
+ mInputFormat(inputFormat),
+ mOutputFormat(outputFormat),
+ mLogger(logger)
+ {
+ }
+
+ unsigned char ulaw2alaw(unsigned char ulaw)
+ {
+ return pjmedia_ulaw2alaw(ulaw);
+ }
+
+ unsigned char alaw2ulaw(unsigned char alaw)
+ {
+ return pjmedia_alaw2ulaw(alaw);
+ }
+
+ FramePtr translate(const FramePtr inFrame)
+ {
+ if (inFrame->mediaFormat->name != mInputFormat->name)
+ {
+ mLogger(Error) << "Cannot translate frame because the format is not what we expect.";
+ throw UnsupportedMediaFormatException();
+ }
+
+ FramePtr outFrame;
+ Ice::ByteSeq outPayload;
+ outPayload.resize(inFrame->payload.size());
+
+ if (inFrame->mediaFormat->name == G711uLAWName)
+ {
+ std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::ulaw2alaw), this));
+ }
+ else
+ {
+ std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::alaw2ulaw), this));
+ }
+
+ outFrame = new Frame(mOutputFormat, outPayload);
+ return outFrame;
+ }
+
+ void translateFrames(const FrameSeq& frames)
+ {
+ FrameSeq translated;
+ translated.resize(frames.size());
+ std::transform(frames.begin(), frames.end(), translated.begin(), std::bind1st(std::mem_fun(&UlawAlawTranslator::translate), this));
+ mSource->distributeToSinks(translated);
+ }
+
+ private:
+ UlawAlawSourcePtr mSource;
+ FormatPtr mInputFormat;
+ FormatPtr mOutputFormat;
+ Logger mLogger;
+ };
+
+ typedef IceUtil::Handle<UlawAlawTranslator> UlawAlawTranslatorPtr;
+
class UlawAlawSink : public StreamSink
{
public:
UlawAlawSink(const Logger& logger,
const FormatPtr& supportedFormat,
- const UlawAlawOperationPtr& translator)
+ const UlawAlawTranslatorPtr& translator)
: mLogger(logger),
mId(IceUtil::generateUUID()),
mTranslator(translator)
@@ -131,6 +202,11 @@ private:
mSupportedFormats.push_back(supportedFormat);
}
+ ~UlawAlawSink()
+ {
+ mLogger(Debug) << "UlawAlawSink destructor called";
+ }
+
void write(const FrameSeq& frames, const Ice::Current&)
{
mTranslator->translateFrames(frames);
@@ -160,7 +236,7 @@ private:
FormatSeq mSupportedFormats;
StreamSourcePrx mSource;
std::string mId;
- UlawAlawOperationPtr mTranslator;
+ UlawAlawTranslatorPtr mTranslator;
};
typedef IceUtil::Handle<UlawAlawSink> UlawAlawSinkPtr;
@@ -176,7 +252,7 @@ public:
mLogger(logger),
mStateItem(new UlawAlawMediaOperationStateItem),
mSource(new UlawAlawSource(mLogger, sourceFormat)),
- mSink(new UlawAlawSink(mLogger, sinkFormat, this)),
+ mSink(new UlawAlawSink(mLogger, sinkFormat, new UlawAlawTranslator(mSource, sinkFormat, sourceFormat, mLogger))),
mReplicationContext(replicationContext)
{
mStateItem->sourceFormat = sourceFormat;
@@ -184,6 +260,21 @@ public:
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)
@@ -252,57 +343,12 @@ public:
{
try
{
- mAdapter->remove(mSourceProxy->ice_getIdentity());
- mAdapter->remove(mSinkProxy->ice_getIdentity());
mAdapter->remove(mProxy->ice_getIdentity());
}
catch (Ice::Exception& ex)
{
- mLogger(Error) << "Exception caught attempting to remove objects from adapter: " << ex.what();
- }
- }
-
- unsigned char ulaw2alaw(unsigned char ulaw)
- {
- return pjmedia_ulaw2alaw(ulaw);
- }
-
- unsigned char alaw2ulaw(unsigned char alaw)
- {
- return pjmedia_alaw2ulaw(alaw);
- }
-
- FramePtr translate(const FramePtr inFrame)
- {
- if (inFrame->mediaFormat->name != mStateItem->sinkFormat->name)
- {
- mLogger(Error) << "Cannot translate frame because the format is not what we expect.";
- throw UnsupportedMediaFormatException();
- }
-
- FramePtr outFrame;
- Ice::ByteSeq outPayload;
- outPayload.resize(inFrame->payload.size());
-
- if (inFrame->mediaFormat->name == G711uLAWName)
- {
- std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawOperation::ulaw2alaw), this));
- }
- else
- {
- std::transform(inFrame->payload.begin(), inFrame->payload.end(), outPayload.begin(), std::bind1st(std::mem_fun(&UlawAlawOperation::alaw2ulaw), this));
+ mLogger(Error) << "Exception caught attempting to remove media operation from adapter: " << ex.what();
}
-
- outFrame = new Frame(mStateItem->sourceFormat, outPayload);
- return outFrame;
- }
-
- void translateFrames(const FrameSeq& frames)
- {
- FrameSeq translated;
- translated.resize(frames.size());
- std::transform(frames.begin(), frames.end(), translated.begin(), std::bind1st(std::mem_fun(&UlawAlawOperation::translate), this));
- mSource->distributeToSinks(translated);
}
private:
commit f148c511a92b2b5626a60cde02d5928449b209a3
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Aug 19 10:28:15 2011 -0500
* Add state replication listener operation for removing state
* Be sure to destroy media operations in our tests.
There is a circular reference I must take care of.
diff --git a/src/MediaOperationStateReplicatorListener.cpp b/src/MediaOperationStateReplicatorListener.cpp
index 59ff82d..66acaca 100644
--- a/src/MediaOperationStateReplicatorListener.cpp
+++ b/src/MediaOperationStateReplicatorListener.cpp
@@ -34,10 +34,11 @@ void MediaOperationStateReplicatorListenerImpl::stateRemoved(
const Ice::StringSeq&,
const Ice::Current&)
{
+ //unimplemented
}
void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
- const MediaOperationStateItemSeq&,
+ const MediaOperationStateItemSeq& items,
const Ice::Current&)
{
class Visitor : public MediaOperationStateItemVisitor
@@ -46,20 +47,11 @@ void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
Visitor(const Ice::ObjectAdapterPtr& adapter)
: mAdapter(adapter) { }
private:
- //XXX VISIT HERE THURSDAY FRIDAY MORNING
void visitUlawAlawMediaOperationStateItem(const UlawAlawMediaOperationStateItemPtr& ulawAlaw)
{
- UlawAlawFactoryPtr factory = UlawAlawFactoryPtr::dynamicCast(mAdapter->find(ulawAlaw->factoryId));
-
- if (!factory)
- {
- return;
- }
-
- factory->createMediaOperation(
- ulawAlaw->sourceFormat,
- ulawAlaw->sinkFormat,
- ulawAlaw->operationId);
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId + ".Source"));
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId + ".Sink"));
+ mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(ulawAlaw->operationId));
}
Ice::ObjectAdapterPtr mAdapter;
};
diff --git a/test/TestMediaOperations.cpp b/test/TestMediaOperations.cpp
index ecb8869..0b5371d 100644
--- a/test/TestMediaOperations.cpp
+++ b/test/TestMediaOperations.cpp
@@ -325,6 +325,9 @@ BOOST_FIXTURE_TEST_CASE(createMediaOperations, PerTestFixture)
BOOST_CHECK(alaw2ulawTranslator != 0);
BOOST_CHECK(ulaw2alawTranslator != 0);
+
+ alaw2ulawTranslator->destroy();
+ ulaw2alawTranslator->destroy();
}
catch (const Ice::Exception& ex)
{
@@ -387,6 +390,8 @@ BOOST_FIXTURE_TEST_CASE(translateAlawToUlaw, PerTestFixture)
//same size as the frame read in.
BOOST_CHECK((*iter)->payload.size() == Testbed.sampleAlawFrame->payload.size());
}
+
+ alaw2ulawTranslator->destroy();
}
BOOST_FIXTURE_TEST_CASE(translateUlawToAlaw, PerTestFixture)
@@ -442,4 +447,6 @@ BOOST_FIXTURE_TEST_CASE(translateUlawToAlaw, PerTestFixture)
//same size as the frame read in.
BOOST_CHECK((*iter)->payload.size() == Testbed.sampleUlawFrame->payload.size());
}
+
+ ulaw2alawTranslator->destroy();
}
commit df280d228311779edaa3fb6ec64d05d754539f93
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Aug 18 18:13:50 2011 -0500
Implement state replication in the media operation I've written.
The last thing I need to do before this can be put up for review is
to implement the stateRemovedForItems method. It shouldn't be too
hard, I just need to leave now.
diff --git a/src/MediaOperationFactoryImpl.cpp b/src/MediaOperationFactoryImpl.cpp
index fa4f0d1..74777f4 100644
--- a/src/MediaOperationFactoryImpl.cpp
+++ b/src/MediaOperationFactoryImpl.cpp
@@ -27,9 +27,11 @@ using namespace AsteriskSCF::Media::V1;
MediaOperationFactoryImpl::MediaOperationFactoryImpl(const Ice::ObjectAdapterPtr& adapter,
const Logger& logger,
+ const MediaOperationReplicationContextPtr& replicationContext,
const std::string& name)
: mAdapter(adapter),
mLogger(logger),
+ mReplicationContext(replicationContext),
mName(name),
mLocatorParams(new MediaOperationServiceLocatorParams)
{
@@ -45,5 +47,15 @@ MediaOperationServiceLocatorParamsPtr MediaOperationFactoryImpl::getLocatorParam
return mLocatorParams;
}
+void MediaOperationFactoryImpl::setProxy(const MediaOperationFactoryPrx& proxy)
+{
+ mProxy = proxy;
+}
+
+MediaOperationFactoryPrx MediaOperationFactoryImpl::getProxy()
+{
+ return mProxy;
+}
+
} //end namespace MediaOperationsCore
} //end namespace AsteriskSCF
diff --git a/src/MediaOperationFactoryImpl.h b/src/MediaOperationFactoryImpl.h
index 48f9d9f..e37b9d0 100644
--- a/src/MediaOperationFactoryImpl.h
+++ b/src/MediaOperationFactoryImpl.h
@@ -21,6 +21,8 @@
#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
#include <AsteriskSCF/logger.h>
+#include "MediaOperationReplicationContext.h"
+
namespace AsteriskSCF
{
@@ -32,6 +34,7 @@ class MediaOperationFactoryImpl : public AsteriskSCF::Media::V1::MediaOperationF
public:
MediaOperationFactoryImpl(const Ice::ObjectAdapterPtr&,
const AsteriskSCF::System::Logging::Logger&,
+ const MediaOperationReplicationContextPtr&,
const std::string&);
virtual AsteriskSCF::Media::V1::MediaOperationPrx createMediaOperation(
@@ -42,20 +45,33 @@ public:
const std::string& getName();
AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr getLocatorParams();
+
+ void setProxy(const AsteriskSCF::Media::V1::MediaOperationFactoryPrx& proxy);
+
+ AsteriskSCF::Media::V1::MediaOperationFactoryPrx getProxy();
protected:
Ice::ObjectAdapterPtr mAdapter;
AsteriskSCF::System::Logging::Logger mLogger;
+
+ /**
+ * Replication context for...replicating state
+ */
+ MediaOperationReplicationContextPtr mReplicationContext;
+
/**
* The name of the factory. Used as a GUID for the service locator params
* that we register.
*/
const std::string mName;
+
/**
* Attributes of this factory.
* Let's the service locator know that we can translate from ulaw to alaw and
* from alaw to ulaw.
*/
AsteriskSCF::Media::V1::MediaOperationServiceLocatorParamsPtr mLocatorParams;
+
+ AsteriskSCF::Media::V1::MediaOperationFactoryPrx mProxy;
};
typedef IceUtil::Handle<MediaOperationFactoryImpl> MediaOperationFactoryImplPtr;
diff --git a/src/MediaOperationStateReplicatorListener.cpp b/src/MediaOperationStateReplicatorListener.cpp
index 99e391f..59ff82d 100644
--- a/src/MediaOperationStateReplicatorListener.cpp
+++ b/src/MediaOperationStateReplicatorListener.cpp
@@ -40,6 +40,37 @@ void MediaOperationStateReplicatorListenerImpl::stateRemovedForItems(
const MediaOperationStateItemSeq&,
const Ice::Current&)
{
+ class Visitor : public MediaOperationStateItemVisitor
+ {
+ public:
+ Visitor(const Ice::ObjectAdapterPtr& adapter)
+ : mAdapter(adapter) { }
+ private:
+ //XXX VISIT HERE THURSDAY FRIDAY MORNING
+ void visitUlawAlawMediaOperationStateItem(const UlawAlawMediaOperationStateItemPtr& ulawAlaw)
+ {
+ UlawAlawFactoryPtr factory = UlawAlawFactoryPtr::dynamicCast(mAdapter->find(ulawAlaw->factoryId));
+
+ if (!factory)
+ {
+ return;
+ }
+
+ factory->createMediaOperation(
+ ulawAlaw->sourceFormat,
+ ulawAlaw->sinkFormat,
+ ulawAlaw->operationId);
+ }
+ Ice::ObjectAdapterPtr mAdapter;
+ };
+
+ MediaOperationStateItemVisitorPtr v = new Visitor(mAdapter);
+
+ for (MediaOperationStateItemSeq::const_iterator iter = items.begin();
+ iter != items.end(); ++iter)
+ {
+ (*iter)->visit(v);
+ }
}
void MediaOperationStateReplicatorListenerImpl::stateSet(
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 2f09a20..11d244e 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -118,14 +118,16 @@ private:
{
MediaOperationFactoryPrx factoryProxy =
MediaOperationFactoryPrx::uncheckedCast(getServiceAdapter()->add(factory, getCommunicator()->stringToIdentity(factory->getName())));
-
+
+ factory->setProxy(factoryProxy);
mFactories.push_back(std::make_pair(factory, factoryProxy));
}
void createOperationFactories()
{
lg(Debug) << "Creating UlawAlawFactory";
- createAndRegisterFactory(new UlawAlawFactory(getServiceAdapter(), lg));
+ createAndRegisterFactory(new UlawAlawFactory(getServiceAdapter(), lg,
+ boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext())));
}
void locateStateReplicator()
diff --git a/src/ulaw_alaw.cpp b/src/ulaw_alaw.cpp
index 475bce5..6d80960 100644
--- a/src/ulaw_alaw.cpp
+++ b/src/ulaw_alaw.cpp
@@ -17,6 +17,7 @@
#include "ulaw_alaw.h"
#include <AsteriskSCF/Media/Formats/AudioFormats.h>
+#include <AsteriskSCF/Replication/MediaOperationsCore/MediaOperationsCoreIf.h>
#include <IceUtil/UUID.h>
#include <pjmedia.h>
@@ -30,6 +31,7 @@ using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::Formats::Audio::V1;
using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Replication::MediaOperationsCore::V1;
class UlawAlawOperation;
typedef IceUtil::Handle<UlawAlawOperation> UlawAlawOperationPtr;
@@ -167,14 +169,57 @@ public:
... 6686 lines suppressed ...
--
asterisk-scf/integration/media_operations_core.git
More information about the asterisk-scf-commits
mailing list