[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Nov 15 14:10:51 CST 2010
branch "master" has been updated
via f5ef900abcadb355b8deff09aaf42d2ac3de2cdd (commit)
from aefcc0fc20ef30fbba4ee26aa4d9d60e26e9609d (commit)
Summary of changes:
src/MediaRTPpjmedia.cpp | 334 +++++++-------
src/RTPSession.cpp | 274 ++++++------
src/RTPSession.h | 36 +-
src/RTPSink.cpp | 216 +++++-----
src/RTPSink.h | 26 +-
src/RTPSource.cpp | 176 ++++----
src/RTPSource.h | 28 +-
test/TestRTPpjmedia.cpp | 1202 +++++++++++++++++++++++-----------------------
8 files changed, 1146 insertions(+), 1146 deletions(-)
- Log -----------------------------------------------------------------
commit f5ef900abcadb355b8deff09aaf42d2ac3de2cdd
Author: David M. Lee <dlee at digium.com>
Date: Mon Nov 15 14:03:38 2010 -0600
Updated indentation to match the style guide.
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 7c8bee7..bddfeda 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -49,23 +49,23 @@ Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
class RTPMediaServiceImpl : public RTPMediaService
{
public:
- RTPMediaServiceImpl(Ice::ObjectAdapterPtr);
- RTPSessionPrx allocate(const FormatSeq&, const Ice::Current&);
+ RTPMediaServiceImpl(Ice::ObjectAdapterPtr);
+ RTPSessionPrx allocate(const FormatSeq&, const Ice::Current&);
private:
- /**
- * A pointer to the object adapter that objects should be added to.
- */
- Ice::ObjectAdapterPtr mAdapter;
-
- /**
- * Memory caching pool.
- */
- pj_caching_pool mCachingPool;
-
- /**
- * Memory pool.
- */
- pj_pool_t* mMemoryPool;
+ /**
+ * A pointer to the object adapter that objects should be added to.
+ */
+ Ice::ObjectAdapterPtr mAdapter;
+
+ /**
+ * Memory caching pool.
+ */
+ pj_caching_pool mCachingPool;
+
+ /**
+ * Memory pool.
+ */
+ pj_pool_t* mMemoryPool;
};
/**
@@ -74,34 +74,34 @@ private:
class MediaRTPpjmediaApp : public IceBox::Service
{
public:
- void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
- void stop();
+ void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
+ void stop();
private:
- /**
- * Ice Communicator used for this service.
- */
- Ice::CommunicatorPtr mCommunicator;
-
- /**
- * Object adapter that everything is associated with.
- */
- Ice::ObjectAdapterPtr mAdapter;
-
- /**
- * The object adapter for the Logger.
- */
- Ice::ObjectAdapterPtr mLoggerAdapter;
-
- /**
- * A proxy to the service locator manager for the RTP media service.
- */
- ServiceManagementPrx mServiceManagement;
-
- /**
- * A proxy to the service locator manager for the component service.
- */
- ServiceManagementPrx mComponentServiceManagement;
+ /**
+ * Ice Communicator used for this service.
+ */
+ Ice::CommunicatorPtr mCommunicator;
+
+ /**
+ * Object adapter that everything is associated with.
+ */
+ Ice::ObjectAdapterPtr mAdapter;
+
+ /**
+ * The object adapter for the Logger.
+ */
+ Ice::ObjectAdapterPtr mLoggerAdapter;
+
+ /**
+ * A proxy to the service locator manager for the RTP media service.
+ */
+ ServiceManagementPrx mServiceManagement;
+
+ /**
+ * A proxy to the service locator manager for the component service.
+ */
+ ServiceManagementPrx mComponentServiceManagement;
};
/**
@@ -110,49 +110,49 @@ private:
class ComponentServiceImpl : public ComponentService
{
public:
- /**
- * A constructor for this implementation which just sets a few variables, nothing extreme.
- */
- ComponentServiceImpl(MediaRTPpjmediaApp& app, ServiceManagementPrx& management) : mApplication(app), mManagement(management) { };
-
- /**
- * An implementation of the suspend method which actually suspends ourselves
- * from the service locator.
- */
- virtual void suspend(const ::Ice::Current&)
- {
- mManagement->suspend();
- }
-
- /**
- * An implementation of the resume method which actually unsuspends ourselves
- * from the service locator.
- */
- virtual void resume(const ::Ice::Current&)
- {
- mManagement->unsuspend();
- }
-
- /**
- * An implementation of the shutdown method which really does shut us down.
- * Goodbye cruel world.
- */
- virtual void shutdown(const ::Ice::Current&)
- {
- // TODO - Actually support this
- }
+ /**
+ * A constructor for this implementation which just sets a few variables, nothing extreme.
+ */
+ ComponentServiceImpl(MediaRTPpjmediaApp& app, ServiceManagementPrx& management) : mApplication(app), mManagement(management) { };
+
+ /**
+ * An implementation of the suspend method which actually suspends ourselves
+ * from the service locator.
+ */
+ virtual void suspend(const ::Ice::Current&)
+ {
+ mManagement->suspend();
+ }
+
+ /**
+ * An implementation of the resume method which actually unsuspends ourselves
+ * from the service locator.
+ */
+ virtual void resume(const ::Ice::Current&)
+ {
+ mManagement->unsuspend();
+ }
+
+ /**
+ * An implementation of the shutdown method which really does shut us down.
+ * Goodbye cruel world.
+ */
+ virtual void shutdown(const ::Ice::Current&)
+ {
+ // TODO - Actually support this
+ }
private:
- /**
- * Our application instance, used for shutting the component down.
- */
- MediaRTPpjmediaApp& mApplication;
-
- /**
- * Our service locator management proxy, we'll use it to suspend and
- * unsuspend ourselves.
- */
- ServiceManagementPrx& mManagement;
+ /**
+ * Our application instance, used for shutting the component down.
+ */
+ MediaRTPpjmediaApp& mApplication;
+
+ /**
+ * Our service locator management proxy, we'll use it to suspend and
+ * unsuspend ourselves.
+ */
+ ServiceManagementPrx& mManagement;
};
/**
@@ -161,10 +161,10 @@ private:
class ThreadDescWrapper
{
public:
- /**
- * pjthread thread description information, must persist for the life of the thread
- */
- pj_thread_desc mDesc;
+ /**
+ * pjthread thread description information, must persist for the life of the thread
+ */
+ pj_thread_desc mDesc;
};
/**
@@ -178,32 +178,32 @@ typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
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);
- pjThreads.insert(make_pair(thread, wrapper));
- }
-
- /**
- * Implementation of the stop function which is called when a thread stops.
- */
- void stop()
- {
- if (pj_thread_is_registered())
- {
- pjThreads.erase(pj_thread_this());
- }
- }
+ /**
+ * 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);
+ pjThreads.insert(make_pair(thread, wrapper));
+ }
+
+ /**
+ * Implementation of the stop function which is called when a thread stops.
+ */
+ void stop()
+ {
+ if (pj_thread_is_registered())
+ {
+ pjThreads.erase(pj_thread_this());
+ }
+ }
private:
- /**
- * A map containing thread lifetime persistent data.
- */
- map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
+ /**
+ * A map containing thread lifetime persistent data.
+ */
+ map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
};
/**
@@ -211,11 +211,11 @@ private:
*/
RTPMediaServiceImpl::RTPMediaServiceImpl(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter)
{
- /* Initialize the memory caching pool using default policy as specified by pjlib. */
- pj_caching_pool_init(&mCachingPool, &pj_pool_factory_default_policy, 0);
+ /* Initialize the memory caching pool using default policy as specified by pjlib. */
+ pj_caching_pool_init(&mCachingPool, &pj_pool_factory_default_policy, 0);
- /* Initialize the memory pool that pjmedia will draw from. */
- mMemoryPool = pj_pool_create(&mCachingPool.factory, "media_rtp_pjmedia", 1000, 1000, NULL);
+ /* Initialize the memory pool that pjmedia will draw from. */
+ mMemoryPool = pj_pool_create(&mCachingPool.factory, "media_rtp_pjmedia", 1000, 1000, NULL);
}
/**
@@ -223,8 +223,8 @@ RTPMediaServiceImpl::RTPMediaServiceImpl(Ice::ObjectAdapterPtr adapter) : mAdapt
*/
RTPSessionPrx RTPMediaServiceImpl::allocate(const FormatSeq& formats, const Ice::Current&)
{
- RTPSessionImplPtr session = new RTPSessionImpl(mAdapter, formats, &mCachingPool.factory);
- return session->getProxy();
+ RTPSessionImplPtr session = new RTPSessionImpl(mAdapter, formats, &mCachingPool.factory);
+ return session->getProxy();
}
/**
@@ -232,63 +232,63 @@ RTPSessionPrx RTPMediaServiceImpl::allocate(const FormatSeq& formats, const Ice:
*/
void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
{
- // we need a logger before we're ready to build the real communicator.
- // use the one we're provided to create the IceLogger.
- mLoggerAdapter = communicator->createObjectAdapter(
- "MediaRTPpjmediaAdapter");
- ConfiguredIceLoggerPtr iceLogger = createIceLogger(mLoggerAdapter);
- getLoggerFactory().setLogOutput(iceLogger->getLogger());
- mLoggerAdapter->activate();
+ // we need a logger before we're ready to build the real communicator.
+ // use the one we're provided to create the IceLogger.
+ mLoggerAdapter = communicator->createObjectAdapter(
+ "MediaRTPpjmediaAdapter");
+ ConfiguredIceLoggerPtr iceLogger = createIceLogger(mLoggerAdapter);
+ getLoggerFactory().setLogOutput(iceLogger->getLogger());
+ mLoggerAdapter->activate();
- /* Initialize pjlib as pjmedia will be using it */
- pj_status_t status = pj_init();
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "PJ library initialization failed.";
- return;
- }
+ /* Initialize pjlib as pjmedia will be using it */
+ pj_status_t status = pj_init();
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "PJ library initialization failed.";
+ return;
+ }
- if ((status = pjlib_util_init()) != PJ_SUCCESS)
- {
- lg(Error) << "PJ Utility library initialization failed.";
- return;
- }
+ if ((status = pjlib_util_init()) != PJ_SUCCESS)
+ {
+ lg(Error) << "PJ Utility library initialization failed.";
+ return;
+ }
- lg(Info) << "Initializing pjmedia rtp component" << endl;
+ lg(Info) << "Initializing pjmedia rtp component" << endl;
- Ice::InitializationData id;
- id.threadHook = new pjlibHook();
- id.properties = communicator->getProperties();
+ Ice::InitializationData id;
+ id.threadHook = new pjlibHook();
+ id.properties = communicator->getProperties();
- mCommunicator = Ice::initialize(id);
+ mCommunicator = Ice::initialize(id);
- mAdapter = mCommunicator->createObjectAdapter("MediaRTPpjmediaAdapter");
+ mAdapter = mCommunicator->createObjectAdapter("MediaRTPpjmediaAdapter");
- RTPMediaServicePtr rtpmediaservice = new RTPMediaServiceImpl(mAdapter);
+ RTPMediaServicePtr rtpmediaservice = new RTPMediaServiceImpl(mAdapter);
- RTPMediaServicePrx RTPMediaServiceProxy = RTPMediaServicePrx::uncheckedCast(mAdapter->addWithUUID(rtpmediaservice));
+ RTPMediaServicePrx RTPMediaServiceProxy = RTPMediaServicePrx::uncheckedCast(mAdapter->addWithUUID(rtpmediaservice));
- mAdapter->activate();
+ mAdapter->activate();
- lg(Info) << "Activated pjmedia rtp component media service." << endl;
+ lg(Info) << "Activated pjmedia rtp component media service." << endl;
- ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
+ ServiceLocatorManagementPrx management = ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
- mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
+ mServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
- /* One must provide a component service to manage us, if someone wants to */
- ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, mServiceManagement);
- ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mAdapter->addWithUUID(ComponentService));
+ /* One must provide a component service to manage us, if someone wants to */
+ ComponentServicePtr ComponentService = new ComponentServiceImpl(*this, mServiceManagement);
+ ComponentServicePrx ComponentServiceProxy = ComponentServicePrx::uncheckedCast(mAdapter->addWithUUID(ComponentService));
- /* Let's add the component service to the service locator first */
- mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
- genericparams->category = "Component/media_rtp_pjmedia";
- mComponentServiceManagement->addLocatorParams(genericparams, "");
+ /* Let's add the component service to the service locator first */
+ mComponentServiceManagement = ServiceManagementPrx::uncheckedCast(management->addService(ComponentServiceProxy, "media_rtp_pjmedia"));
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ genericparams->category = "Component/media_rtp_pjmedia";
+ mComponentServiceManagement->addLocatorParams(genericparams, "");
- /* Now we can add some parameters to help find us. */
- genericparams->category = "rtp";
- mServiceManagement->addLocatorParams(genericparams, "");
+ /* Now we can add some parameters to help find us. */
+ genericparams->category = "rtp";
+ mServiceManagement->addLocatorParams(genericparams, "");
}
/**
@@ -296,15 +296,15 @@ void MediaRTPpjmediaApp::start(const std::string& name, const Ice::CommunicatorP
*/
void MediaRTPpjmediaApp::stop()
{
- mComponentServiceManagement->unregister();
- mServiceManagement->unregister();
- mCommunicator->destroy();
+ mComponentServiceManagement->unregister();
+ mServiceManagement->unregister();
+ mCommunicator->destroy();
}
extern "C"
{
- ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
- {
- return new MediaRTPpjmediaApp;
- }
+ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr communicator)
+{
+ return new MediaRTPpjmediaApp;
+}
}
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index e9566bc..b61a4a2 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -47,63 +47,63 @@ using namespace AsteriskSCF::Media::RTP::V1;
class RTPSessionImplPriv
{
public:
- RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats) : mAdapter(adapter), mFormats(formats) { };
- ~RTPSessionImplPriv();
-
- /**
- * A pointer to the object adapter that objects should be added to.
- */
- Ice::ObjectAdapterPtr mAdapter;
-
- /**
- * A sequence of formats that the session is expected to carry.
- */
- FormatSeq mFormats;
-
- /**
- * A proxy to ourselves.
- */
- RTPSessionPrx mProxy;
-
- /**
- * pjmedia endpoint for our media.
- */
- pjmedia_endpt* mEndpoint;
-
- /**
- * pjmedia transport for transmission/reception of RTP.
- */
- pjmedia_transport* mTransport;
-
- /**
- * A stream source for this RTP session.
- */
- StreamSourceRTPImplPtr mStreamSource;
-
- /**
- * A proxy to the above mentioned stream source.
- */
- StreamSourceRTPPrx mStreamSourceProxy;
-
- /**
- * A stream sink for this RTP session.
- */
- StreamSinkRTPPtr mStreamSink;
-
- /**
- * A proxy to the above mentioned stream sink.
- */
- StreamSinkRTPPrx mStreamSinkProxy;
-
- /**
- * A dictionary mapping payloads to media formats.
- */
- PayloadMap mPayloadstoFormats;
-
- /**
- * A dictionary mapping media formats to payloads.
- */
- map<string, int> mFormatstoPayloads;
+ RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats) : mAdapter(adapter), mFormats(formats) { };
+ ~RTPSessionImplPriv();
+
+ /**
+ * A pointer to the object adapter that objects should be added to.
+ */
+ Ice::ObjectAdapterPtr mAdapter;
+
+ /**
+ * A sequence of formats that the session is expected to carry.
+ */
+ FormatSeq mFormats;
+
+ /**
+ * A proxy to ourselves.
+ */
+ RTPSessionPrx mProxy;
+
+ /**
+ * pjmedia endpoint for our media.
+ */
+ pjmedia_endpt* mEndpoint;
+
+ /**
+ * pjmedia transport for transmission/reception of RTP.
+ */
+ pjmedia_transport* mTransport;
+
+ /**
+ * A stream source for this RTP session.
+ */
+ StreamSourceRTPImplPtr mStreamSource;
+
+ /**
+ * A proxy to the above mentioned stream source.
+ */
+ StreamSourceRTPPrx mStreamSourceProxy;
+
+ /**
+ * A stream sink for this RTP session.
+ */
+ StreamSinkRTPPtr mStreamSink;
+
+ /**
+ * A proxy to the above mentioned stream sink.
+ */
+ StreamSinkRTPPrx mStreamSinkProxy;
+
+ /**
+ * A dictionary mapping payloads to media formats.
+ */
+ PayloadMap mPayloadstoFormats;
+
+ /**
+ * A dictionary mapping media formats to payloads.
+ */
+ map<string, int> mFormatstoPayloads;
};
/**
@@ -111,33 +111,33 @@ public:
*/
RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats, pj_pool_factory* factory) : mImpl(new RTPSessionImplPriv(adapter, formats))
{
- /* Add ourselves to the ICE ASM so we can be used. */
- mImpl->mProxy = RTPSessionPrx::uncheckedCast(adapter->addWithUUID(this));
-
- /* Create an endpoint in pjmedia for our media. */
- pj_status_t status = pjmedia_endpt_create(factory, NULL, 1, &mImpl->mEndpoint);
-
- if (status != PJ_SUCCESS)
- {
- /* TODO: This is bad... we can't go on! */
- }
-
- /* Now create some transport we can use to actually send or receive the media. */
- for (int port = DEFAULT_RTP_PORT_MINIMUM; port < DEFAULT_RTP_PORT_MAXIMUM; port += 2)
- {
- if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) == PJ_SUCCESS)
- {
- break;
- }
- }
-
- /* First up for our own stuff is... a source! Media needs to come from somewhere, you know. */
- mImpl->mStreamSource = new StreamSourceRTPImpl(this);
- mImpl->mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSource));
-
- /* And for my next trick a place for us to send media out. */
- mImpl->mStreamSink = new StreamSinkRTPImpl(this);
- mImpl->mStreamSinkProxy = StreamSinkRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSink));
+ /* Add ourselves to the ICE ASM so we can be used. */
+ mImpl->mProxy = RTPSessionPrx::uncheckedCast(adapter->addWithUUID(this));
+
+ /* Create an endpoint in pjmedia for our media. */
+ pj_status_t status = pjmedia_endpt_create(factory, NULL, 1, &mImpl->mEndpoint);
+
+ if (status != PJ_SUCCESS)
+ {
+ /* TODO: This is bad... we can't go on! */
+ }
+
+ /* Now create some transport we can use to actually send or receive the media. */
+ for (int port = DEFAULT_RTP_PORT_MINIMUM; port < DEFAULT_RTP_PORT_MAXIMUM; port += 2)
+ {
+ if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) == PJ_SUCCESS)
+ {
+ break;
+ }
+ }
+
+ /* First up for our own stuff is... a source! Media needs to come from somewhere, you know. */
+ mImpl->mStreamSource = new StreamSourceRTPImpl(this);
+ mImpl->mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSource));
+
+ /* And for my next trick a place for us to send media out. */
+ mImpl->mStreamSink = new StreamSinkRTPImpl(this);
+ mImpl->mStreamSinkProxy = StreamSinkRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSink));
}
/**
@@ -145,11 +145,11 @@ RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& f
*/
RTPSessionImplPriv::~RTPSessionImplPriv()
{
- /* Discontinue the media transport. */
- pjmedia_transport_close(mTransport);
+ /* Discontinue the media transport. */
+ pjmedia_transport_close(mTransport);
- /* Discontinue the media endpoint. */
- pjmedia_endpt_destroy(mEndpoint);
+ /* Discontinue the media endpoint. */
+ pjmedia_endpt_destroy(mEndpoint);
}
/**
@@ -157,10 +157,10 @@ RTPSessionImplPriv::~RTPSessionImplPriv()
*/
StreamSourceSeq RTPSessionImpl::getSources(const Ice::Current&)
{
- /* We only support one stream source per RTP session right now, so just return the one. */
- StreamSourceSeq sources;
- sources.push_back(mImpl->mStreamSourceProxy);
- return sources;
+ /* We only support one stream source per RTP session right now, so just return the one. */
+ StreamSourceSeq sources;
+ sources.push_back(mImpl->mStreamSourceProxy);
+ return sources;
}
/**
@@ -168,10 +168,10 @@ StreamSourceSeq RTPSessionImpl::getSources(const Ice::Current&)
*/
StreamSinkSeq RTPSessionImpl::getSinks(const Ice::Current&)
{
- /* We only support one stream sink per RTP session right now, so just return the one. */
- StreamSinkSeq sinks;
- sinks.push_back(mImpl->mStreamSinkProxy);
- return sinks;
+ /* We only support one stream sink per RTP session right now, so just return the one. */
+ StreamSinkSeq sinks;
+ sinks.push_back(mImpl->mStreamSinkProxy);
+ return sinks;
}
/**
@@ -179,10 +179,10 @@ StreamSinkSeq RTPSessionImpl::getSinks(const Ice::Current&)
*/
std::string RTPSessionImpl::getId(const Ice::Current&)
{
- /* Instead of having to maintain our own identifier for this RTP session we can use the identifier
- * created when it was added to the ICE ASM.
- */
- return mImpl->mProxy->ice_getIdentity().name;
+ /* Instead of having to maintain our own identifier for this RTP session we can use the identifier
+ * created when it was added to the ICE ASM.
+ */
+ return mImpl->mProxy->ice_getIdentity().name;
}
/**
@@ -197,8 +197,8 @@ void RTPSessionImpl::useRTCP(bool, const Ice::Current&)
*/
RTCPSessionPrx RTPSessionImpl::getRTCPSession(const Ice::Current&)
{
- RTCPSessionPrx proxy;
- return proxy;
+ RTCPSessionPrx proxy;
+ return proxy;
}
/**
@@ -206,20 +206,20 @@ RTCPSessionPrx RTPSessionImpl::getRTCPSession(const Ice::Current&)
*/
void RTPSessionImpl::release(const Ice::Current&)
{
- /* Drop the source and sink from the ASM */
- mImpl->mAdapter->remove(mImpl->mStreamSourceProxy->ice_getIdentity());
- mImpl->mAdapter->remove(mImpl->mStreamSinkProxy->ice_getIdentity());
-
- /* Since both the source and sink have a pointer back to the session we need to get rid of them,
- * which will in turn get rid of ourselves once we are removed from the ASM.
- */
- mImpl->mStreamSource = 0;
- mImpl->mStreamSink = 0;
-
- /* All we have to do is remove ourselves from the ASM, our smart pointerness will cause us to
- * destruct and then cleanup will occur.
- */
- mImpl->mAdapter->remove(mImpl->mProxy->ice_getIdentity());
+ /* Drop the source and sink from the ASM */
+ mImpl->mAdapter->remove(mImpl->mStreamSourceProxy->ice_getIdentity());
+ mImpl->mAdapter->remove(mImpl->mStreamSinkProxy->ice_getIdentity());
+
+ /* Since both the source and sink have a pointer back to the session we need to get rid of them,
+ * which will in turn get rid of ourselves once we are removed from the ASM.
+ */
+ mImpl->mStreamSource = 0;
+ mImpl->mStreamSink = 0;
+
+ /* All we have to do is remove ourselves from the ASM, our smart pointerness will cause us to
+ * destruct and then cleanup will occur.
+ */
+ mImpl->mAdapter->remove(mImpl->mProxy->ice_getIdentity());
}
/**
@@ -227,12 +227,12 @@ void RTPSessionImpl::release(const Ice::Current&)
*/
void RTPSessionImpl::associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap& mappings, const Ice::Current&)
{
- mImpl->mPayloadstoFormats = mappings;
+ mImpl->mPayloadstoFormats = mappings;
- for (PayloadMap::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
- {
- mImpl->mFormatstoPayloads.insert(make_pair((*it).second->name, (*it).first));
- }
+ for (PayloadMap::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
+ {
+ mImpl->mFormatstoPayloads.insert(make_pair((*it).second->name, (*it).first));
+ }
}
/**
@@ -242,7 +242,7 @@ void RTPSessionImpl::associatePayloads(const AsteriskSCF::Media::RTP::V1::Payloa
*/
RTPSessionPrx RTPSessionImpl::getProxy()
{
- return mImpl->mProxy;
+ return mImpl->mProxy;
}
/**
@@ -252,7 +252,7 @@ RTPSessionPrx RTPSessionImpl::getProxy()
*/
pjmedia_transport* RTPSessionImpl::getTransport()
{
- return mImpl->mTransport;
+ return mImpl->mTransport;
}
/**
@@ -262,7 +262,7 @@ pjmedia_transport* RTPSessionImpl::getTransport()
*/
FormatSeq RTPSessionImpl::getFormats()
{
- return mImpl->mFormats;
+ return mImpl->mFormats;
}
/**
@@ -270,7 +270,7 @@ FormatSeq RTPSessionImpl::getFormats()
*/
void RTPSessionImpl::setRemoteDetails(std::string address, int port)
{
- mImpl->mStreamSource->setRemoteDetails(address, port);
+ mImpl->mStreamSource->setRemoteDetails(address, port);
}
/**
@@ -280,14 +280,14 @@ void RTPSessionImpl::setRemoteDetails(std::string address, int port)
*/
FormatPtr RTPSessionImpl::getFormat(int payload)
{
- PayloadMap::iterator it = mImpl->mPayloadstoFormats.find(payload);
+ PayloadMap::iterator it = mImpl->mPayloadstoFormats.find(payload);
- if (it == mImpl->mPayloadstoFormats.end())
- {
- return 0;
- }
+ if (it == mImpl->mPayloadstoFormats.end())
+ {
+ return 0;
+ }
- return (*it).second;
+ return (*it).second;
}
/**
@@ -297,12 +297,12 @@ FormatPtr RTPSessionImpl::getFormat(int payload)
*/
int RTPSessionImpl::getPayload(const FormatPtr& mediaformat)
{
- map<string, int>::iterator it = mImpl->mFormatstoPayloads.find(mediaformat->name);
+ map<string, int>::iterator it = mImpl->mFormatstoPayloads.find(mediaformat->name);
- if (it == mImpl->mFormatstoPayloads.end())
- {
- return -1;
- }
+ if (it == mImpl->mFormatstoPayloads.end())
+ {
+ return -1;
+ }
- return (*it).second;
+ return (*it).second;
}
diff --git a/src/RTPSession.h b/src/RTPSession.h
index 93c580e..ff9585d 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -21,25 +21,25 @@ class RTPSessionImplPriv;
class RTPSessionImpl : public AsteriskSCF::Media::RTP::V1::RTPSession
{
public:
- RTPSessionImpl(Ice::ObjectAdapterPtr, const AsteriskSCF::Media::V1::FormatSeq&, pj_pool_factory*);
- AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&);
- AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
- std::string getId(const Ice::Current&);
- void useRTCP(bool, const Ice::Current&);
- AsteriskSCF::Media::RTP::V1::RTCPSessionPrx getRTCPSession(const Ice::Current&);
- void release(const Ice::Current&);
- AsteriskSCF::Media::RTP::V1::RTPSessionPrx getProxy();
- pjmedia_transport* getTransport();
- AsteriskSCF::Media::V1::FormatSeq getFormats();
- void associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap&, const Ice::Current&);
- void setRemoteDetails(std::string address, int port);
- AsteriskSCF::Media::V1::FormatPtr getFormat(int payload);
- int getPayload(const AsteriskSCF::Media::V1::FormatPtr& mediaformat);
+ RTPSessionImpl(Ice::ObjectAdapterPtr, const AsteriskSCF::Media::V1::FormatSeq&, pj_pool_factory*);
+ AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&);
+ AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
+ std::string getId(const Ice::Current&);
+ void useRTCP(bool, const Ice::Current&);
+ AsteriskSCF::Media::RTP::V1::RTCPSessionPrx getRTCPSession(const Ice::Current&);
+ void release(const Ice::Current&);
+ AsteriskSCF::Media::RTP::V1::RTPSessionPrx getProxy();
+ pjmedia_transport* getTransport();
+ AsteriskSCF::Media::V1::FormatSeq getFormats();
+ void associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap&, const Ice::Current&);
+ void setRemoteDetails(std::string address, int port);
+ AsteriskSCF::Media::V1::FormatPtr getFormat(int payload);
+ int getPayload(const AsteriskSCF::Media::V1::FormatPtr& mediaformat);
private:
- /**
- * Private implementation data for RTPSessionImpl.
- */
- boost::shared_ptr<RTPSessionImplPriv> mImpl;
+ /**
+ * Private implementation data for RTPSessionImpl.
+ */
+ boost::shared_ptr<RTPSessionImplPriv> mImpl;
};
/**
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index f89776a..3e80164 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -36,35 +36,35 @@ using namespace AsteriskSCF::Media::RTP::V1;
class StreamSinkRTPImplPriv
{
public:
- /**
- * Constructor for our StreamSinkRTPImplPriv class.
- */
- StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mRemotePort(0) { pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand()); };
-
- /**
- * A structure containing outgoing pjmedia session data.
- */
- pjmedia_rtp_session mOutgoingSession;
-
- /**
- * A pointer to the RTP session we are associated with.
- */
- RTPSessionImplPtr mSession;
-
- /**
- * A proxy to the sink that we are receiving media from.
- */
- StreamSourcePrx mSource;
-
- /**
- * The IP address that we are configured to send media to.
- */
- string mRemoteAddress;
-
- /**
- * The port that we are configured to send media to.
- */
- int mRemotePort;
+ /**
+ * Constructor for our StreamSinkRTPImplPriv class.
+ */
+ StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mRemotePort(0) { pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand()); };
+
+ /**
+ * A structure containing outgoing pjmedia session data.
+ */
+ pjmedia_rtp_session mOutgoingSession;
+
+ /**
+ * A pointer to the RTP session we are associated with.
+ */
+ RTPSessionImplPtr mSession;
+
+ /**
+ * A proxy to the sink that we are receiving media from.
+ */
+ StreamSourcePrx mSource;
+
+ /**
+ * The IP address that we are configured to send media to.
+ */
+ string mRemoteAddress;
+
+ /**
+ * The port that we are configured to send media to.
+ */
+ int mRemotePort;
};
/**
@@ -79,60 +79,60 @@ StreamSinkRTPImpl::StreamSinkRTPImpl(RTPSessionImplPtr session) : mImpl(new Stre
*/
void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
{
- // Don't even bother if no remote address information is present
- if (mImpl->mRemoteAddress.empty() || !mImpl->mRemotePort)
- {
- return;
- }
-
- for (FrameSeq::const_iterator frame = frames.begin(); frame != frames.end(); ++frame)
- {
- AudioFormatPtr audioformat;
-
- /* TODO: Add support for other types of media */
- if (!(audioformat = AudioFormatPtr::dynamicCast((*frame)->mediaformat)))
- {
- continue;
- }
-
- const void *header;
- int header_len;
- int payload;
-
- // Only allow media formats through that we support
- if ((payload = mImpl->mSession->getPayload((*frame)->mediaformat)) < 0)
- {
- throw UnsupportedMediaFormatException();
- }
-
- /* Using the available information construct an RTP header that we can place at the front of our packet */
- pj_status_t status = pjmedia_rtp_encode_rtp(&mImpl->mOutgoingSession, mImpl->mSession->getPayload((*frame)->mediaformat), 0, (*frame)->payload.size(),
- (*frame)->payload.size(), &header, &header_len);
-
- if (status != PJ_SUCCESS)
- {
- /* TODO: What should we do in this case? */
- continue;
- }
-
- /* Now we have to construct the entire packet containing RTP header and the payload from the frame */
- char packet[1500];
-
- /* Copy the header itself that we produced in */
- pj_memcpy(packet, (const pjmedia_rtp_hdr*)header, header_len);
-
- /* Now the actual payload */
- pj_memcpy(packet + header_len, &(*frame)->payload[0], (*frame)->payload.size());
-
- /* All done, transmission can now occur */
- status = pjmedia_transport_send_rtp(mImpl->mSession->getTransport(), packet, (*frame)->payload.size() + header_len);
-
- if (status != PJ_SUCCESS)
- {
- /* TODO: Transmission failed... what to do? */
- continue;
- }
- }
+ // Don't even bother if no remote address information is present
+ if (mImpl->mRemoteAddress.empty() || !mImpl->mRemotePort)
+ {
+ return;
+ }
+
+ for (FrameSeq::const_iterator frame = frames.begin(); frame != frames.end(); ++frame)
+ {
+ AudioFormatPtr audioformat;
+
+ /* TODO: Add support for other types of media */
+ if (!(audioformat = AudioFormatPtr::dynamicCast((*frame)->mediaformat)))
+ {
+ continue;
+ }
+
+ const void *header;
+ int header_len;
+ int payload;
+
+ // Only allow media formats through that we support
+ if ((payload = mImpl->mSession->getPayload((*frame)->mediaformat)) < 0)
+ {
+ throw UnsupportedMediaFormatException();
+ }
+
+ /* Using the available information construct an RTP header that we can place at the front of our packet */
+ pj_status_t status = pjmedia_rtp_encode_rtp(&mImpl->mOutgoingSession, mImpl->mSession->getPayload((*frame)->mediaformat), 0, (*frame)->payload.size(),
+ (*frame)->payload.size(), &header, &header_len);
+
+ if (status != PJ_SUCCESS)
+ {
+ /* TODO: What should we do in this case? */
+ continue;
+ }
+
+ /* Now we have to construct the entire packet containing RTP header and the payload from the frame */
+ char packet[1500];
+
+ /* Copy the header itself that we produced in */
+ pj_memcpy(packet, (const pjmedia_rtp_hdr*)header, header_len);
+
+ /* Now the actual payload */
+ pj_memcpy(packet + header_len, &(*frame)->payload[0], (*frame)->payload.size());
+
+ /* All done, transmission can now occur */
+ status = pjmedia_transport_send_rtp(mImpl->mSession->getTransport(), packet, (*frame)->payload.size() + header_len);
+
+ if (status != PJ_SUCCESS)
+ {
+ /* TODO: Transmission failed... what to do? */
+ continue;
+ }
+ }
}
/**
@@ -140,7 +140,7 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
*/
void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
{
- mImpl->mSource = source;
+ mImpl->mSource = source;
}
/**
@@ -148,7 +148,7 @@ void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&
*/
AsteriskSCF::Media::V1::StreamSourcePrx StreamSinkRTPImpl::getSource(const Ice::Current&)
{
- return mImpl->mSource;
+ return mImpl->mSource;
}
/**
@@ -156,7 +156,7 @@ AsteriskSCF::Media::V1::StreamSourcePrx StreamSinkRTPImpl::getSource(const Ice::
*/
AsteriskSCF::Media::V1::FormatSeq StreamSinkRTPImpl::getFormats(const Ice::Current&)
{
- return mImpl->mSession->getFormats();
+ return mImpl->mSession->getFormats();
}
/**
@@ -164,8 +164,8 @@ AsteriskSCF::Media::V1::FormatSeq StreamSinkRTPImpl::getFormats(const Ice::Curre
*/
std::string StreamSinkRTPImpl::getId(const Ice::Current& current)
{
- /* For now utilize the id of the session */
- return mImpl->mSession->getId(current);
+ /* For now utilize the id of the session */
+ return mImpl->mSession->getId(current);
}
/**
@@ -173,16 +173,16 @@ std::string StreamSinkRTPImpl::getId(const Ice::Current& current)
*/
void StreamSinkRTPImpl::setRemoteDetails(const std::string& address, Ice::Int port, const Ice::Current&)
{
- /* This method is essentially a passthru to the RTPSourceImpl. It takes care of
- * actually attaching the transport.
- */
- mImpl->mSession->setRemoteDetails(address, port);
-
- /* We do store it though in case we have not yet received a packet from the remote side but
- * are asked for the remote address.
- */
- mImpl->mRemoteAddress = address;
- mImpl->mRemotePort = port;
+ /* This method is essentially a passthru to the RTPSourceImpl. It takes care of
+ * actually attaching the transport.
+ */
+ mImpl->mSession->setRemoteDetails(address, port);
+
+ /* We do store it though in case we have not yet received a packet from the remote side but
+ * are asked for the remote address.
+ */
+ mImpl->mRemoteAddress = address;
+ mImpl->mRemotePort = port;
}
/**
@@ -190,13 +190,13 @@ void StreamSinkRTPImpl::setRemoteDetails(const std::string& address, Ice::Int po
*/
std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
{
- pjmedia_transport_info transportInfo;
+ pjmedia_transport_info transportInfo;
- pjmedia_transport_info_init(&transportInfo);
- pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
- string address = pj_inet_ntoa(transportInfo.src_rtp_name.ipv4.sin_addr);
- return (address != "0.0.0.0") ? address : mImpl->mRemoteAddress;
+ string address = pj_inet_ntoa(transportInfo.src_rtp_name.ipv4.sin_addr);
+ return (address != "0.0.0.0") ? address : mImpl->mRemoteAddress;
}
/**
@@ -204,11 +204,11 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
*/
Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
{
- pjmedia_transport_info transportInfo;
+ pjmedia_transport_info transportInfo;
- pjmedia_transport_info_init(&transportInfo);
- pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
- int port = pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
- return (port != 0) ? port : mImpl->mRemotePort;
+ int port = pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
+ return (port != 0) ? port : mImpl->mRemotePort;
}
diff --git a/src/RTPSink.h b/src/RTPSink.h
index 555e54d..81562ab 100644
--- a/src/RTPSink.h
+++ b/src/RTPSink.h
@@ -21,18 +21,18 @@ class StreamSinkRTPImplPriv;
class StreamSinkRTPImpl : public AsteriskSCF::Media::RTP::V1::StreamSinkRTP
{
public:
- StreamSinkRTPImpl(RTPSessionImplPtr);
- void write(const AsteriskSCF::Media::V1::FrameSeq&, const Ice::Current&);
- void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&, 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&);
- void setRemoteDetails(const std::string&, Ice::Int, const Ice::Current&);
- std::string getRemoteAddress(const Ice::Current&);
- Ice::Int getRemotePort(const Ice::Current&);
+ StreamSinkRTPImpl(RTPSessionImplPtr);
+ void write(const AsteriskSCF::Media::V1::FrameSeq&, const Ice::Current&);
+ void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&, 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&);
+ void setRemoteDetails(const std::string&, Ice::Int, const Ice::Current&);
+ std::string getRemoteAddress(const Ice::Current&);
+ Ice::Int getRemotePort(const Ice::Current&);
private:
- /**
- * Private implementation data for StreamSinkRTPImpl.
- */
- boost::shared_ptr<StreamSinkRTPImplPriv> mImpl;
+ /**
+ * Private implementation data for StreamSinkRTPImpl.
+ */
+ boost::shared_ptr<StreamSinkRTPImplPriv> mImpl;
};
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index e933ea0..e25aaf0 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -43,25 +43,25 @@ Logger &lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
class StreamSourceRTPImplPriv
{
public:
- /**
- * Constructor for our StreamSourceRTPImplPriv class.
- */
- StreamSourceRTPImplPriv(RTPSessionImplPtr session) : mSession(session) { pjmedia_rtp_session_init(&mIncomingSession, 0, 0); };
-
- /**
- * A structure containing incoming pjmedia session data.
- */
- pjmedia_rtp_session mIncomingSession;
-
- /**
- * A pointer to the RTP session we are associated with.
- */
- RTPSessionImplPtr mSession;
-
- /**
- * A proxy to the sink that we are writing incoming media to.
- */
- StreamSinkPrx mSink;
+ /**
+ * Constructor for our StreamSourceRTPImplPriv class.
+ */
+ StreamSourceRTPImplPriv(RTPSessionImplPtr session) : mSession(session) { pjmedia_rtp_session_init(&mIncomingSession, 0, 0); };
+
+ /**
+ * A structure containing incoming pjmedia session data.
+ */
+ pjmedia_rtp_session mIncomingSession;
+
+ /**
+ * A pointer to the RTP session we are associated with.
+ */
+ RTPSessionImplPtr mSession;
+
+ /**
+ * A proxy to the sink that we are writing incoming media to.
+ */
+ StreamSinkPrx mSink;
};
/**
@@ -76,7 +76,7 @@ StreamSourceRTPImpl::StreamSourceRTPImpl(RTPSessionImplPtr session) : mImpl(new
*/
void StreamSourceRTPImpl::setSink(const AsteriskSCF::Media::V1::StreamSinkPrx& sink, const Ice::Current&)
{
- mImpl->mSink = sink;
+ mImpl->mSink = sink;
}
/**
@@ -84,7 +84,7 @@ void StreamSourceRTPImpl::setSink(const AsteriskSCF::Media::V1::StreamSinkPrx& s
*/
AsteriskSCF::Media::V1::StreamSinkPrx StreamSourceRTPImpl::getSink(const Ice::Current&)
{
- return mImpl->mSink;
+ return mImpl->mSink;
}
/**
@@ -92,7 +92,7 @@ AsteriskSCF::Media::V1::StreamSinkPrx StreamSourceRTPImpl::getSink(const Ice::Cu
*/
AsteriskSCF::Media::V1::FormatSeq StreamSourceRTPImpl::getFormats(const Ice::Current&)
{
- return mImpl->mSession->getFormats();
+ return mImpl->mSession->getFormats();
}
/**
@@ -100,8 +100,8 @@ AsteriskSCF::Media::V1::FormatSeq StreamSourceRTPImpl::getFormats(const Ice::Cur
*/
std::string StreamSourceRTPImpl::getId(const Ice::Current& current)
{
- /* For now utilize the id of the session */
- return mImpl->mSession->getId(current);
+ /* For now utilize the id of the session */
+ return mImpl->mSession->getId(current);
}
/**
@@ -109,8 +109,8 @@ std::string StreamSourceRTPImpl::getId(const Ice::Current& current)
*/
void StreamSourceRTPImpl::requestFormat(const AsteriskSCF::Media::V1::FormatPtr&, const Ice::Current&)
{
- /* We do not currently support switching formats. */
- throw new MediaFormatSwitchException();
+ /* We do not currently support switching formats. */
+ throw new MediaFormatSwitchException();
}
/**
@@ -118,12 +118,12 @@ void StreamSourceRTPImpl::requestFormat(const AsteriskSCF::Media::V1::FormatPtr&
*/
std::string StreamSourceRTPImpl::getLocalAddress(const Ice::Current&)
{
- pjmedia_transport_info transportInfo;
+ pjmedia_transport_info transportInfo;
- pjmedia_transport_info_init(&transportInfo);
- pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
- return pj_inet_ntoa(transportInfo.sock_info.rtp_addr_name.ipv4.sin_addr);
+ return pj_inet_ntoa(transportInfo.sock_info.rtp_addr_name.ipv4.sin_addr);
}
/**
@@ -131,12 +131,12 @@ std::string StreamSourceRTPImpl::getLocalAddress(const Ice::Current&)
*/
Ice::Int StreamSourceRTPImpl::getLocalPort(const Ice::Current&)
{
- pjmedia_transport_info transportInfo;
+ pjmedia_transport_info transportInfo;
- pjmedia_transport_info_init(&transportInfo);
- pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
- return pj_ntohs(transportInfo.sock_info.rtp_addr_name.ipv4.sin_port);
+ return pj_ntohs(transportInfo.sock_info.rtp_addr_name.ipv4.sin_port);
}
/**
@@ -144,59 +144,59 @@ Ice::Int StreamSourceRTPImpl::getLocalPort(const Ice::Current&)
*/
static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
{
- StreamSourceRTPImpl* source = static_cast<StreamSourceRTPImpl*>(userdata);
+ StreamSourceRTPImpl* source = static_cast<StreamSourceRTPImpl*>(userdata);
- /* Ensure that no errors occurred when reading this packet in */
- if (size < 0)
- {
- lg(Error) << "We attempted to read data from an RTP session but failed.";
- return;
- }
+ /* Ensure that no errors occurred when reading this packet in */
+ if (size < 0)
+ {
+ lg(Error) << "We attempted to read data from an RTP session but failed.";
+ return;
+ }
- const pjmedia_rtp_hdr* header;
- Ice::Byte* payload;
- unsigned int payload_size;
+ const pjmedia_rtp_hdr* header;
+ Ice::Byte* payload;
+ unsigned int payload_size;
- pj_status_t status = pjmedia_rtp_decode_rtp(&source->mImpl->mIncomingSession, packet, size, &header, (const void**)&payload, &payload_size);
+ pj_status_t status = pjmedia_rtp_decode_rtp(&source->mImpl->mIncomingSession, packet, size, &header, (const void**)&payload, &payload_size);
- if (status != PJ_SUCCESS)
- {
- lg(Error) << "We read an RTP packet of size " << size << " in but failed to decode it.";
- return;
- }
+ if (status != PJ_SUCCESS)
+ {
+ lg(Error) << "We read an RTP packet of size " << size << " in but failed to decode it.";
+ return;
+ }
- if (source->mImpl->mSink != 0)
- {
- FormatPtr mediaformat = source->mImpl->mSession->getFormat(header->pt);
+ if (source->mImpl->mSink != 0)
+ {
+ FormatPtr mediaformat = source->mImpl->mSession->getFormat(header->pt);
- if (mediaformat != 0)
- {
- FrameSeq frames;
+ if (mediaformat != 0)
+ {
+ FrameSeq frames;
- AudioFormatPtr audioformat;
+ AudioFormatPtr audioformat;
- if ((audioformat = AudioFormatPtr::dynamicCast(mediaformat)))
- {
- AudioFramePtr frame = new AudioFrame();
- frame->mediaformat = mediaformat;
+ if ((audioformat = AudioFormatPtr::dynamicCast(mediaformat)))
+ {
+ AudioFramePtr frame = new AudioFrame();
+ frame->mediaformat = mediaformat;
- /* Populate the common data */
- frame->timestamp = header->ts;
- frame->seqno = header->seq;
+ /* Populate the common data */
+ frame->timestamp = header->ts;
+ frame->seqno = header->seq;
- /* Copy the payload from the RTP packet to the frame, yahoo! */
- copy(payload, payload + payload_size, std::back_inserter(frame->payload));
+ /* Copy the payload from the RTP packet to the frame, yahoo! */
+ copy(payload, payload + payload_size, std::back_inserter(frame->payload));
- /* Into the sequence it goes, yarrrrrrrrrr matey */
- frames.push_back(frame);
- }
+ /* Into the sequence it goes, yarrrrrrrrrr matey */
+ frames.push_back(frame);
+ }
- source->mImpl->mSink->write(frames);
- }
- }
+ source->mImpl->mSink->write(frames);
+ }
+ }
- /* Now that all is said and done update the internal RTP stack state */
- pjmedia_rtp_session_update(&source->mImpl->mIncomingSession, header, NULL);
+ /* Now that all is said and done update the internal RTP stack state */
+ pjmedia_rtp_session_update(&source->mImpl->mIncomingSession, header, NULL);
}
/**
@@ -204,23 +204,23 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
*/
void StreamSourceRTPImpl::setRemoteDetails(std::string address, int port)
{
- pj_sockaddr_in sin;
+ pj_sockaddr_in sin;
- /* This feels so dirty but convert from our std::string to a pj_str, since their API requires it. */
- pj_str_t tmpAddress;
- pj_strset(&tmpAddress, (char*)address.c_str(), address.size());
+ /* This feels so dirty but convert from our std::string to a pj_str, since their API requires it. */
+ pj_str_t tmpAddress;
+ pj_strset(&tmpAddress, (char*)address.c_str(), address.size());
- /* Now for the next trick - convert into a pj_sockaddr_in so we can pass it to pjmedia_transport_attach */
- pj_sockaddr_in_init(&sin, &tmpAddress, port);
+ /* Now for the next trick - convert into a pj_sockaddr_in so we can pass it to pjmedia_transport_attach */
+ pj_sockaddr_in_init(&sin, &tmpAddress, port);
- /* In case we were already attached go ahead and detach */
- pjmedia_transport_detach(mImpl->mSession->getTransport(), this);
+ /* In case we were already attached go ahead and detach */
+ pjmedia_transport_detach(mImpl->mSession->getTransport(), this);
- /* All ready... actually do it! */
- pj_status_t status = pjmedia_transport_attach(mImpl->mSession->getTransport(), this, &sin, NULL, sizeof(pj_sockaddr_in), &receiveRTP, NULL);
+ /* All ready... actually do it! */
+ pj_status_t status = pjmedia_transport_attach(mImpl->mSession->getTransport(), this, &sin, NULL, sizeof(pj_sockaddr_in), &receiveRTP, NULL);
- if (status != PJ_SUCCESS)
- {
- /* TODO: Decide what to do if this occurs, do we need an exception? */
- }
+ if (status != PJ_SUCCESS)
+ {
+ /* TODO: Decide what to do if this occurs, do we need an exception? */
+ }
}
diff --git a/src/RTPSource.h b/src/RTPSource.h
index ab74e14..bd92dea 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -21,21 +21,21 @@ class StreamSourceRTPImplPriv;
class StreamSourceRTPImpl : public AsteriskSCF::Media::RTP::V1::StreamSourceRTP
{
public:
- StreamSourceRTPImpl(RTPSessionImplPtr);
- void setSink(const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
- AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&);
- AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&);
- std::string getId(const Ice::Current&);
- void requestFormat(const AsteriskSCF::Media::V1::FormatPtr&, const Ice::Current&);
- std::string getLocalAddress(const Ice::Current&);
- Ice::Int getLocalPort(const Ice::Current&);
- void setRemoteDetails(std::string address, int port);
+ StreamSourceRTPImpl(RTPSessionImplPtr);
+ void setSink(const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
+ AsteriskSCF::Media::V1::StreamSinkPrx getSink(const Ice::Current&);
+ AsteriskSCF::Media::V1::FormatSeq getFormats(const Ice::Current&);
+ std::string getId(const Ice::Current&);
+ void requestFormat(const AsteriskSCF::Media::V1::FormatPtr&, const Ice::Current&);
+ std::string getLocalAddress(const Ice::Current&);
+ Ice::Int getLocalPort(const Ice::Current&);
+ void setRemoteDetails(std::string address, int port);
- /**
- * Private implementation data for StreamSourceRTPImpl.
- * Note: This is public on purpose so that our RTP callback can access it.
- */
- boost::shared_ptr<StreamSourceRTPImplPriv> mImpl;
+ /**
+ * Private implementation data for StreamSourceRTPImpl.
+ * Note: This is public on purpose so that our RTP callback can access it.
+ */
+ boost::shared_ptr<StreamSourceRTPImplPriv> mImpl;
};
/**
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index d27b4f4..bd882f2 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -20,7 +20,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/test/debug.hpp>
-#include <boost/thread/thread.hpp>
+#include <boost/thread/thread.hpp>
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
@@ -40,18 +40,18 @@ using namespace AsteriskSCF::Media::RTP::V1;
class MediaRTPpjmediaTest : public IceBox::Service
{
public:
- void start(const std::string&,
- const Ice::CommunicatorPtr&,
- const Ice::StringSeq&);
- void stop();
+ void start(const std::string&,
+ const Ice::CommunicatorPtr&,
+ const Ice::StringSeq&);
+ void stop();
};
/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
struct ArgCacheType
{
public:
- int argc;
- char **argv;
+ int argc;
+ char **argv;
};
static ArgCacheType mCachedArgs;
@@ -62,86 +62,86 @@ static ArgCacheType mCachedArgs;
struct SharedTestData
{
public:
- /**
- * ICE Communicator used for talking to the service locator and eventually media format service.
- */
- Ice::CommunicatorPtr communicator;
-
- /**
- * A proxy to the service locator service.
- */
- ServiceLocatorPrx locator;
-
- /**
- * A proxy to the RTP session that we requested.
- */
- RTPSessionPrx session;
-
- /**
- * A proxy to our test sink.
- */
- StreamSinkPrx sink;
-
- /**
- * Object adapter that the sink is on.
- */
- Ice::ObjectAdapterPtr adapter;
-
- /**
- * A sequence containing frames received via RTP.
- */
- FrameSeq frames;
+ /**
+ * ICE Communicator used for talking to the service locator and eventually media format service.
+ */
+ Ice::CommunicatorPtr communicator;
+
+ /**
+ * A proxy to the service locator service.
+ */
+ ServiceLocatorPrx locator;
+
+ /**
+ * A proxy to the RTP session that we requested.
+ */
+ RTPSessionPrx session;
+
+ /**
+ * A proxy to our test sink.
+ */
+ StreamSinkPrx sink;
+
+ /**
+ * Object adapter that the sink is on.
+ */
+ Ice::ObjectAdapterPtr adapter;
+
+ /**
+ * A sequence containing frames received via RTP.
+ */
+ FrameSeq frames;
};
static SharedTestData Testbed;
class TestStreamSink : public StreamSink
{
public:
- /**
- * Implementation of the write method which doesn't really do anything yet.
- */
- void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
- {
- Testbed.frames = frames;
- }
-
- /**
- * Implementation of the setSource method which just stores the source away for later retrieval.
- */
- void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
- {
- mSource = source;
- }
-
- /**
- * Implementation of the getSource method which just pulls the source back out.
- */
- StreamSourcePrx getSource(const Ice::Current&)
- {
- return mSource;
- }
-
- /**
- * Implementation of the getFormats method which returns... wait for it... no methods!
- */
- FormatSeq getFormats(const Ice::Current&)
- {
- FormatSeq formats;
- return formats;
- }
-
- /**
- * Implementation of the getId which currently returns a hardcoded value.
- */
- std::string getId(const Ice::Current&)
- {
- return "bob";
- }
+ /**
+ * Implementation of the write method which doesn't really do anything yet.
+ */
+ void write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
+ {
+ Testbed.frames = frames;
+ }
+
+ /**
+ * Implementation of the setSource method which just stores the source away for later retrieval.
+ */
+ void setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
+ {
+ mSource = source;
+ }
+
+ /**
+ * Implementation of the getSource method which just pulls the source back out.
+ */
+ StreamSourcePrx getSource(const Ice::Current&)
+ {
+ return mSource;
+ }
+
+ /**
+ * Implementation of the getFormats method which returns... wait for it... no methods!
+ */
+ FormatSeq getFormats(const Ice::Current&)
+ {
+ FormatSeq formats;
+ return formats;
+ }
+
+ /**
+ * Implementation of the getId which currently returns a hardcoded value.
+ */
+ std::string getId(const Ice::Current&)
+ {
+ return "bob";
+ }
private:
- /**
- * The source that is sending us media.
- */
- StreamSourcePrx mSource;
+ /**
+ * The source that is sending us media.
+ */
+ StreamSourcePrx mSource;
};
/**
@@ -150,55 +150,55 @@ private:
*/
struct GlobalIceFixture
{
- GlobalIceFixture()
- {
- BOOST_TEST_MESSAGE("Setting up pjmedia rtp media test fixture");
+ GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Setting up pjmedia rtp media test fixture");
- ::boost::debug::detect_memory_leaks(false);
- ::boost::unit_test::unit_test_log.set_stream( std::cout );
+ ::boost::debug::detect_memory_leaks(false);
+ ::boost::unit_test::unit_test_log.set_stream( std::cout );
- int status = 0;
- try
- {
- Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
+ int status = 0;
+ try
+ {
+ Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
- Testbed.adapter = Testbed.communicator->createObjectAdapterWithEndpoints("SinkAdapter", "default");
+ Testbed.adapter = Testbed.communicator->createObjectAdapterWithEndpoints("SinkAdapter", "default");
- StreamSinkPtr sink = new TestStreamSink();
+ StreamSinkPtr sink = new TestStreamSink();
- Testbed.sink = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(sink));
+ Testbed.sink = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(sink));
- Testbed.adapter->activate();
+ Testbed.adapter->activate();
- Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 4411"));
+ Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 4411"));
- if (!Testbed.locator) {
- throw "Invalid service locator proxy";
- }
- }
- catch (const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = 1;
- }
- catch (const char* msg)
- {
- cerr << msg << endl;
- status = 1;
- }
+ if (!Testbed.locator) {
+ throw "Invalid service locator proxy";
+ }
+ }
+ catch (const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = 1;
+ }
+ catch (const char* msg)
+ {
+ cerr << msg << endl;
+ status = 1;
+ }
- } // end Fixture() constructor
+ } // end Fixture() constructor
- ~GlobalIceFixture()
- {
- BOOST_TEST_MESSAGE("Tearing down pjmedia rtp media test fixture");
+ ~GlobalIceFixture()
+ {
+ BOOST_TEST_MESSAGE("Tearing down pjmedia rtp media test fixture");
- if (Testbed.communicator) {
- Testbed.communicator->shutdown();
- Testbed.communicator = 0;
- }
- }
+ if (Testbed.communicator) {
+ Testbed.communicator->shutdown();
+ Testbed.communicator = 0;
+ }
+ }
private:
};
@@ -209,22 +209,22 @@ BOOST_GLOBAL_FIXTURE(GlobalIceFixture);
*/
BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
{
- bool found = false;
+ bool found = false;
- try {
- ServiceLocatorParamsPtr params = new ServiceLocatorParams();
- params->category = "rtp";
+ try {
+ ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+ params->category = "rtp";
- Testbed.locator->locate(params);
+ Testbed.locator->locate(params);
- found = true;
- } catch (const Ice::Exception &e) {
- BOOST_TEST_MESSAGE(e.ice_name());
- BOOST_TEST_MESSAGE(e.what());
- } catch (...) {
- }
+ found = true;
+ } catch (const Ice::Exception &e) {
+ BOOST_TEST_MESSAGE(e.ice_name());
+ BOOST_TEST_MESSAGE(e.what());
+ } catch (...) {
+ }
- BOOST_CHECK(found);
+ BOOST_CHECK(found);
}
/**
@@ -232,36 +232,36 @@ BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
*/
BOOST_AUTO_TEST_CASE(AllocateRTPSession)
{
- bool allocated = false;
+ bool allocated = false;
- try
- {
- ServiceLocatorParamsPtr params = new ServiceLocatorParams();
- params->category = "rtp";
+ try
+ {
+ ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+ params->category = "rtp";
- RTPMediaServicePrx service = RTPMediaServicePrx::uncheckedCast(Testbed.locator->locate(params));
+ RTPMediaServicePrx service = RTPMediaServicePrx::uncheckedCast(Testbed.locator->locate(params));
- AudioFormatPtr format = new AudioFormat();
- format->name = "test_format";
- format->frameSize = 20;
+ AudioFormatPtr format = new AudioFormat();
+ format->name = "test_format";
+ format->frameSize = 20;
- FormatSeq formats;
- formats.push_back(format);
+ FormatSeq formats;
+ formats.push_back(format);
- Testbed.session = service->allocate(formats);
+ Testbed.session = service->allocate(formats);
- allocated = true;
- }
- catch (const Ice::Exception &e)
- {
- BOOST_TEST_MESSAGE(e.ice_name());
- BOOST_TEST_MESSAGE(e.what());
- }
- catch (...)
- {
- }
+ allocated = true;
+ }
+ catch (const Ice::Exception &e)
+ {
+ BOOST_TEST_MESSAGE(e.ice_name());
+ BOOST_TEST_MESSAGE(e.what());
+ }
+ catch (...)
+ {
+ }
- BOOST_CHECK(allocated);
+ BOOST_CHECK(allocated);
}
/**
@@ -269,27 +269,27 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
*/
BOOST_AUTO_TEST_CASE(CheckForSource)
{
- bool hassource = false;
-
- try
- {
- StreamSourceSeq sources = Testbed.session->getSources();
-
- if (sources.size() > 0)
- {
- hassource = true;
- }
- }
- catch (const Ice::Exception &e)
- {
- BOOST_TEST_MESSAGE(e.ice_name());
- BOOST_TEST_MESSAGE(e.what());
- }
- catch (...)
- {
- }
-
- BOOST_CHECK(hassource);
+ bool hassource = false;
+
+ try
+ {
+ StreamSourceSeq sources = Testbed.session->getSources();
+
+ if (sources.size() > 0)
+ {
+ hassource = true;
+ }
+ }
+ catch (const Ice::Exception &e)
+ {
+ BOOST_TEST_MESSAGE(e.ice_name());
+ BOOST_TEST_MESSAGE(e.what());
+ }
+ catch (...)
+ {
+ }
+
+ BOOST_CHECK(hassource);
}
/**
@@ -297,34 +297,34 @@ BOOST_AUTO_TEST_CASE(CheckForSource)
*/
BOOST_AUTO_TEST_CASE(VerifyLocalAddressonSources)
{
- bool validaddresses = true;
-
- try
- {
- StreamSourceSeq sources = Testbed.session->getSources();
-
- for (StreamSourceSeq::const_iterator i = sources.begin(); i != sources.end(); ++i)
- {
- StreamSourceRTPPrx source = StreamSourceRTPPrx::checkedCast((*i));
-
- if (source->getLocalAddress().empty() || !source->getLocalPort())
- {
- validaddresses = false;
- }
- }
- }
- catch (const Ice::Exception &e)
- {
- BOOST_TEST_MESSAGE(e.ice_name());
- BOOST_TEST_MESSAGE(e.what());
- validaddresses = false;
- }
- catch (...)
- {
- validaddresses = false;
- }
-
- BOOST_CHECK(validaddresses);
+ bool validaddresses = true;
+
+ try
+ {
+ StreamSourceSeq sources = Testbed.session->getSources();
+
+ for (StreamSourceSeq::const_iterator i = sources.begin(); i != sources.end(); ++i)
+ {
+ StreamSourceRTPPrx source = StreamSourceRTPPrx::checkedCast((*i));
+
+ if (source->getLocalAddress().empty() || !source->getLocalPort())
+ {
+ validaddresses = false;
+ }
+ }
+ }
+ catch (const Ice::Exception &e)
+ {
+ BOOST_TEST_MESSAGE(e.ice_name());
+ BOOST_TEST_MESSAGE(e.what());
... 915 lines suppressed ...
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list