[asterisk-scf-commits] asterisk-scf/release/media_rtp_pjmedia.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu May 19 11:38:05 CDT 2011
branch "master" has been updated
via 10900df1422c8cdd3c43173863a6c7f8087f9801 (commit)
from d0f0dfa8e7260ee3d7bf94fe4edc7e9cf7cb858a (commit)
Summary of changes:
local-slice/RtpStateReplicationIf.ice | 2 +
src/MediaRTPpjmedia.cpp | 64 +++++++++++++++++++++---
src/RTPSession.cpp | 17 ++++--
src/RTPSession.h | 8 ++--
src/RTPSink.cpp | 22 +++++++--
src/RTPSource.cpp | 33 ++++++++++---
src/RtpStateReplicatorListener.cpp | 3 +-
test/CMakeLists.txt | 9 ++++
test/TestRTPpjmedia.cpp | 86 +++++++++++++++++++++++++++++---
9 files changed, 206 insertions(+), 38 deletions(-)
- Log -----------------------------------------------------------------
commit 10900df1422c8cdd3c43173863a6c7f8087f9801
Author: Joshua Colp <jcolp at digium.com>
Date: Sun May 8 11:56:18 2011 -0300
Add support for IPv6.
diff --git a/local-slice/RtpStateReplicationIf.ice b/local-slice/RtpStateReplicationIf.ice
index 254b50e..90a534a 100644
--- a/local-slice/RtpStateReplicationIf.ice
+++ b/local-slice/RtpStateReplicationIf.ice
@@ -74,6 +74,7 @@ module V1
class RtpGeneralStateItem extends RtpStateItem
{
AsteriskSCF::Core::Discovery::V1::ServiceManagement *mServiceManagement;
+ string mComparatorId;
};
class RtpSessionStateItem extends RtpStateItem
@@ -84,6 +85,7 @@ module V1
Ice::Identity mSourceIdentity;
AsteriskSCF::Media::V1::FormatSeq mFormats;
PayloadMap mPayloadstoFormats;
+ bool mIPv6;
};
class RtpStreamSinkStateItem extends RtpStateItem
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index ab63f28..3fb0964 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -52,6 +52,7 @@ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
static const string ReplicaServiceId("MediaRtpReplica");
static const string MediaServiceId("RTPMediaService");
+static const string MediaComparatorServiceId("RTPMediaServiceComparator");
/**
* Implementation of the RTPMediaService interface as defined in MediaRTPIf.ice
@@ -60,8 +61,8 @@ class RTPMediaServiceImpl : public RTPMediaService
{
public:
RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&, const ReplicaPtr&,
- const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>&);
- RTPSessionPrx allocate(const FormatSeq&, const Ice::Current&);
+ const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>&);
+ RTPSessionPrx allocate(const RTPServiceLocatorParamsPtr&, const Ice::Current&);
pj_pool_factory *getPoolFactory() { return &mCachingPool.factory; };
private:
/**
@@ -161,6 +162,37 @@ private:
};
/**
+ * Implementation of the ServiceLocatorParamsCompare class
+ */
+class RTPMediaServiceCompareServiceImpl : public ServiceLocatorParamsCompare
+{
+public:
+ bool isSupported(const ServiceLocatorParamsPtr& locatorParams, const Ice::Current&)
+ {
+ RTPServiceLocatorParamsPtr params;
+
+ if (!(params = RTPServiceLocatorParamsPtr::dynamicCast(locatorParams)))
+ {
+ return false;
+ }
+
+ bool result = true;
+
+ // This is done on purpose for additional checks in the future
+ if (params->ipv6 == true)
+ {
+#ifdef PJ_HAS_IPV6
+ result = true;
+#else
+ result = false;
+#endif
+ }
+
+ return result;
+ };
+};
+
+/**
* Implementation of the IceBox::Service class
*/
class MediaRTPpjmediaApp : public IceBox::Service
@@ -341,10 +373,10 @@ RTPMediaServiceImpl::RTPMediaServiceImpl(const Ice::ObjectAdapterPtr& adapter, c
/**
* Implementation of the allocate method as defined in MediaRTPIf.ice
*/
-RTPSessionPrx RTPMediaServiceImpl::allocate(const FormatSeq& formats, const Ice::Current&)
+RTPSessionPrx RTPMediaServiceImpl::allocate(const RTPServiceLocatorParamsPtr& params, const Ice::Current&)
{
RTPSessionImplPtr session =
- new RTPSessionImpl(mAdapter, formats, &mCachingPool.factory, mReplicaService, mStateReplicator);
+ new RTPSessionImpl(mAdapter, params, &mCachingPool.factory, mReplicaService, mStateReplicator);
return session->getProxy();
}
@@ -440,20 +472,33 @@ void MediaRTPpjmediaApp::start(const std::string&, const Ice::CommunicatorPtr& c
}
}
+ ServiceLocatorParamsComparePtr rtpmediacomparatorservice = new RTPMediaServiceCompareServiceImpl();
+ ServiceLocatorParamsComparePrx RTPMediaComparatorServiceProxy = ServiceLocatorParamsComparePrx::uncheckedCast(
+ mGlobalAdapter->add(rtpmediacomparatorservice, mCommunicator->stringToIdentity(MediaComparatorServiceId)));
+
+ if (mReplicaService->isActive() == true)
+ {
+ mGeneralState->mComparatorId = IceUtil::generateUUID();
+ management->addCompare(mGeneralState->mComparatorId, RTPMediaComparatorServiceProxy);
+ }
+
+
RTPMediaServicePrx RTPMediaServiceProxy = RTPMediaServicePrx::uncheckedCast(mGlobalAdapter->add(rtpmediaservice,
mCommunicator->stringToIdentity(MediaServiceId)));
- ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+ RTPServiceLocatorParamsPtr rtpparams = new RTPServiceLocatorParams();
if (mReplicaService->isActive() == true)
{
mGeneralState->mServiceManagement = ServiceManagementPrx::uncheckedCast(
management->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
/* Now we can add some parameters to help find us. */
- genericparams->category = "rtp";
- mGeneralState->mServiceManagement->addLocatorParams(genericparams, "");
+ rtpparams->category = "rtp";
+ mGeneralState->mServiceManagement->addLocatorParams(rtpparams, mGeneralState->mComparatorId);
}
+ ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
+
/* One must provide a component service to manage us, if someone wants to */
ComponentServicePtr ComponentService = new ComponentServicepjmediaImpl(*this, mGeneralState);
ComponentServicePrx ComponentServiceProxy =
@@ -483,7 +528,10 @@ void MediaRTPpjmediaApp::stop()
mComponentServiceManagement->unregister();
if (mReplicaService->isActive() == true)
{
- mGeneralState-> mServiceManagement->unregister();
+ mGeneralState->mServiceManagement->unregister();
+ ServiceLocatorManagementPrx management =
+ ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
+ management->removeCompare(mGeneralState->mComparatorId);
}
mCommunicator->destroy();
}
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 2cddb39..bf97327 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -130,10 +130,10 @@ public:
/**
* Constructor for the RTPSessionImpl class (used by Ice).
*/
-RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const FormatSeq& formats,
+RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const RTPServiceLocatorParamsPtr& params,
pj_pool_factory* factory, const ReplicaPtr& replicaService,
const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>& stateReplicator) :
- mImpl(new RTPSessionImplPriv(adapter, formats, replicaService, stateReplicator))
+ mImpl(new RTPSessionImplPriv(adapter, params->formats, replicaService, stateReplicator))
{
/* Add ourselves to the ICE ASM so we can be used. */
mImpl->mProxy = RTPSessionPrx::uncheckedCast(adapter->addWithUUID(this));
@@ -146,10 +146,12 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const Forma
/* TODO: This is bad... we can't go on! */
}
+ int af = (params->ipv6 == true) ? pj_AF_INET6() : pj_AF_INET();
+
/* 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)) ==
+ if ((status = pjmedia_transport_udp_create3(mImpl->mEndpoint, af, "RTP", NULL, port, 0, &mImpl->mTransport)) ==
PJ_SUCCESS)
{
mImpl->mSessionStateItem->mPort = port;
@@ -160,7 +162,8 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const Forma
// Initialize our session state item enough so that the state items for the source and sink can also be initialized.
mImpl->mSessionStateItem->key = mImpl->mSessionStateItem->mSessionId = IceUtil::generateUUID();
mImpl->mSessionStateItem->mSessionIdentity = mImpl->mProxy->ice_getIdentity();
- mImpl->mSessionStateItem->mFormats = formats;
+ mImpl->mSessionStateItem->mFormats = params->formats;
+ mImpl->mSessionStateItem->mIPv6 = params->ipv6;
/* First up for our own stuff is... a source! Media needs to come from somewhere, you know. */
mImpl->mStreamSource = new StreamSourceRTPImpl(this, mImpl->mSessionStateItem->key);
@@ -181,7 +184,7 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const Forma
*/
RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, pj_pool_factory* factory,
const Ice::Identity& sessionIdentity, const Ice::Identity& sinkIdentity, const Ice::Identity& sourceIdentity,
- Ice::Int port, const FormatSeq& formats) :
+ Ice::Int port, const FormatSeq& formats, bool ipv6) :
mImpl(new RTPSessionImplPriv(adapter, formats, 0, *(new AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>)))
{
mImpl->mProxy = RTPSessionPrx::uncheckedCast(adapter->add(this, sessionIdentity));
@@ -193,7 +196,9 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, pj_pool_fac
/* TODO: This is bad... we can't go on! */
}
- if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport))
+ int af = (ipv6 == true) ? pj_AF_INET6() : pj_AF_INET();
+
+ if ((status = pjmedia_transport_udp_create3(mImpl->mEndpoint, af, "RTP", NULL, port, 0, &mImpl->mTransport))
!= PJ_SUCCESS)
{
// TODO: This is also bad, something is using the port */
diff --git a/src/RTPSession.h b/src/RTPSession.h
index 1703cd0..6638b14 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -42,11 +42,11 @@ typedef IceUtil::Handle<StreamSourceRTPImpl> StreamSourceRTPImplPtr;
class RTPSessionImpl : public AsteriskSCF::Media::RTP::V1::RTPSession
{
public:
- RTPSessionImpl(const Ice::ObjectAdapterPtr&, const AsteriskSCF::Media::V1::FormatSeq&,
- pj_pool_factory*, const AsteriskSCF::System::Component::V1::ReplicaPtr&,
- const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Media::RTP::V1::RtpStateReplicatorPrx>&);
+ RTPSessionImpl(const Ice::ObjectAdapterPtr&, const AsteriskSCF::Media::RTP::V1::RTPServiceLocatorParamsPtr&,
+ pj_pool_factory*, const AsteriskSCF::System::Component::V1::ReplicaPtr&,
+ const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Media::RTP::V1::RtpStateReplicatorPrx>&);
RTPSessionImpl(const Ice::ObjectAdapterPtr&, pj_pool_factory*, const Ice::Identity&, const Ice::Identity&,
- const Ice::Identity&, Ice::Int, const AsteriskSCF::Media::V1::FormatSeq&);
+ const Ice::Identity&, Ice::Int, const AsteriskSCF::Media::V1::FormatSeq&, bool);
AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&);
AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&);
std::string getId(const Ice::Current&);
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 5c591b3..41e7b18 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -208,8 +208,17 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
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->mSinkStateItem->mRemoteAddress;
+ if (transportInfo.src_rtp_name.addr.sa_family != PJ_AF_INET &&
+ transportInfo.src_rtp_name.addr.sa_family != PJ_AF_INET6)
+ {
+ // If we have no remote address yet (we know because the default initialization
+ // for the above is neither PJ_AF_INET or PJ_AF_INET6) then return whatever
+ // remote address we have been told, heck, it could be blank!
+ return mImpl->mSinkStateItem->mRemoteAddress;
+ }
+
+ char tmp_addr[PJ_INET6_ADDRSTRLEN];
+ return pj_sockaddr_print(&transportInfo.src_rtp_name, tmp_addr, sizeof(tmp_addr), 0);
}
/**
@@ -222,8 +231,13 @@ Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
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->mSinkStateItem->mRemotePort;
+ if (transportInfo.src_rtp_name.addr.sa_family != PJ_AF_INET &&
+ transportInfo.src_rtp_name.addr.sa_family != PJ_AF_INET6)
+ {
+ return mImpl->mSinkStateItem->mRemotePort;
+ }
+
+ return pj_sockaddr_get_port(&transportInfo.src_rtp_name);
}
/**
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 6a8e1a7..3bc22c1 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -140,7 +140,8 @@ std::string StreamSourceRTPImpl::getLocalAddress(const Ice::Current&)
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);
+ char tmp_addr[PJ_INET6_ADDRSTRLEN];
+ return pj_sockaddr_print(&transportInfo.sock_info.rtp_addr_name, tmp_addr, sizeof(tmp_addr), 0);
}
/**
@@ -153,7 +154,7 @@ Ice::Int StreamSourceRTPImpl::getLocalPort(const Ice::Current&)
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_sockaddr_get_port(&transportInfo.sock_info.rtp_addr_name);
}
/**
@@ -232,24 +233,42 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
*/
void StreamSourceRTPImpl::setRemoteDetails(const string& address, Ice::Int port)
{
- pj_sockaddr_in sin;
+ pj_sockaddr addr;
/* 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, (pj_uint16_t) port);
+ /* Now for the next trick - convert into a pj_sockaddr so we can pass it to pjmedia_transport_attach */
+ pj_status_t status = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &tmpAddress, &addr);
+
+ if (status != PJ_SUCCESS)
+ {
+ throw InvalidAddress();
+ }
+
+ // Confirm that the address family of the address matches that of this RTP session
+ pjmedia_transport_info transportInfo;
+
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+
+ if (transportInfo.sock_info.rtp_addr_name.addr.sa_family != addr.addr.sa_family)
+ {
+ throw InvalidAddress();
+ }
+
+ pj_sockaddr_set_port(&addr, static_cast<pj_uint16_t>(port));
/* 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);
+ status = pjmedia_transport_attach(mImpl->mSession->getTransport(), this, &addr, NULL, pj_sockaddr_get_len(&addr), &receiveRTP, NULL);
if (status != PJ_SUCCESS)
{
- /* TODO: Decide what to do if this occurs, do we need an exception? */
+ throw InvalidAddress();
}
}
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index fd5694c..2bfab90 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -81,6 +81,7 @@ public:
void visitRtpGeneralStateItem(const RtpGeneralStateItemPtr &item)
{
mImpl->mGeneralState->mServiceManagement = item->mServiceManagement;
+ mImpl->mGeneralState->mComparatorId = item->mComparatorId;
}
void visitRtpSessionStateItem(const RtpSessionStateItemPtr &item)
@@ -96,7 +97,7 @@ public:
RTPSessionImplPtr localSession =
new RTPSessionImpl(mImpl->mAdapter, mImpl->mPoolFactory, item->mSessionIdentity,
- item->mSinkIdentity, item->mSourceIdentity, item->mPort, item->mFormats);
+ item->mSinkIdentity, item->mSourceIdentity, item->mPort, item->mFormats, item->mIPv6);
localitem->setSession(localSession);
}
else
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c82fb29..f65d5b2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,7 +9,16 @@ asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test unit_test_fram
asterisk_scf_component_build_icebox(media_rtp_pjmedia_test)
target_link_libraries(media_rtp_pjmedia_test asterisk-scf-api)
+add_definitions(-DIPV6_TEST)
+asterisk_scf_component_init(media_rtp_pjmedia_test_v6)
+asterisk_scf_component_add_file(media_rtp_pjmedia_test_v6 TestRTPpjmedia.cpp)
+asterisk_scf_component_add_slice(media_rtp_pjmedia_test_v6 ../local-slice/RtpStateReplicationIf.ice)
+asterisk_scf_component_add_boost_libraries(media_rtp_pjmedia_test_v6 unit_test_framework thread date_time)
+asterisk_scf_component_build_icebox(media_rtp_pjmedia_test_v6)
+target_link_libraries(media_rtp_pjmedia_test_v6 asterisk-scf-api)
+
# integration test
if(integrated_build STREQUAL "true")
asterisk_scf_test_icebox(media_rtp_pjmedia_test config/test_component.config)
+ asterisk_scf_test_icebox(media_rtp_pjmedia_test_v6 config/test_component.config)
endif()
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index a13f157..810963e 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -13,7 +13,11 @@
* the GNU General Public License Version 2. See the LICENSE.txt file
* at the top of the source tree.
*/
+#ifdef IPV6_TEST
+#define BOOST_TEST_MODULE RTPpjmediaTestSuitev6
+#else
#define BOOST_TEST_MODULE RTPpjmediaTestSuite
+#endif
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
@@ -313,7 +317,7 @@ BOOST_AUTO_TEST_CASE(ServiceFoundUsingName)
bool found = false;
try {
- ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+ RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
params->category = "rtp";
Testbed.locator->locate(params);
@@ -396,6 +400,8 @@ BOOST_AUTO_TEST_CASE(CheckReplicatedGeneralStateItem)
}
BOOST_CHECK(Testbed.mListener->mGeneral);
+ BOOST_CHECK(Testbed.mListener->mGeneral->mServiceManagement);
+ BOOST_CHECK(Testbed.mListener->mGeneral->mComparatorId.size());
}
/**
@@ -407,8 +413,11 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
try
{
- ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+ RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
params->category = "rtp";
+#ifdef IPV6_TEST
+ params->ipv6 = true;
+#endif
RTPMediaServicePrx service = RTPMediaServicePrx::uncheckedCast(Testbed.locator->locate(params));
@@ -422,7 +431,7 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
// You might think "geez, this should deadlock due to state replication" but no, we use one ways for that
boost::mutex::scoped_lock lock(Testbed.mLock);
- Testbed.session = service->allocate(formats);
+ Testbed.session = service->allocate(params);
// Give the RTP component time to replicate this session
Testbed.mCondition.wait(lock);
@@ -449,6 +458,12 @@ BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSession)
BOOST_CHECK(Testbed.mListener->mSession);
BOOST_CHECK(Testbed.mListener->mSession->mSessionIdentity == Testbed.session->ice_getIdentity());
+#ifdef IPV6_TEST
+ BOOST_CHECK(Testbed.mListener->mSession->mIPv6 == true);
+#else
+ BOOST_CHECK(Testbed.mListener->mSession->mIPv6 == false);
+#endif
+
StreamSinkSeq sinks = Testbed.session->getSinks();
StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
BOOST_CHECK(Testbed.mListener->mSession->mSinkIdentity == sink->ice_getIdentity());
@@ -521,8 +536,15 @@ BOOST_AUTO_TEST_CASE(VerifyLocalAddressonSources)
for (StreamSourceSeq::const_iterator i = sources.begin(); i != sources.end(); ++i)
{
StreamSourceRTPPrx source = StreamSourceRTPPrx::checkedCast((*i));
+ std::string address = source->getLocalAddress();
+
+#ifdef IPV6_TEST
+ std::string valid_char = ":";
+#else
+ std::string valid_char = ".";
+#endif
- if (source->getLocalAddress().empty() || !source->getLocalPort())
+ if (address.empty() || !source->getLocalPort() || address.find(valid_char) == string::npos)
{
validaddresses = false;
}
@@ -669,9 +691,14 @@ BOOST_AUTO_TEST_CASE(ConfirmRemoteAddressSetting)
{
StreamSinkRTPPrx sink = StreamSinkRTPPrx::checkedCast((*i));
- sink->setRemoteDetails("127.0.0.1", 10000);
+#ifdef IPV6_TEST
+ std::string address = "::1";
+#else
+ std::string address = "127.0.0.1";
+#endif
+ sink->setRemoteDetails(address, 10000);
- if (sink->getRemoteAddress() == "127.0.0.1" && sink->getRemotePort() == 10000)
+ if (sink->getRemoteAddress() == address && sink->getRemotePort() == 10000)
{
set = true;
}
@@ -952,8 +979,11 @@ BOOST_AUTO_TEST_CASE(ReceiveUnknownRTPPacket)
try
{
- ServiceLocatorParamsPtr params = new ServiceLocatorParams();
+ RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
params->category = "rtp";
+#ifdef IPV6_TEST
+ params->ipv6 = true;
+#endif
RTPMediaServicePrx service = RTPMediaServicePrx::uncheckedCast(Testbed.locator->locate(params));
@@ -964,7 +994,7 @@ BOOST_AUTO_TEST_CASE(ReceiveUnknownRTPPacket)
FormatSeq formats;
formats.push_back(format);
- RTPSessionPrx session = service->allocate(formats);
+ RTPSessionPrx session = service->allocate(params);
PayloadMap mapping;
mapping.insert(make_pair(13, format));
@@ -1017,6 +1047,46 @@ BOOST_AUTO_TEST_CASE(ReceiveUnknownRTPPacket)
}
/**
+ * Attempt to set an IPv4 address on an IPv6 only sink OR try to set an IPv6 address
+ * on an IPv4 only sink.
+ */
+BOOST_AUTO_TEST_CASE(SetInvalidAddressFamilyAddress)
+{
+ bool set = false;
+
+ try
+ {
+ StreamSinkSeq sinks = Testbed.session->getSinks();
+
+ for (StreamSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+ {
+ StreamSinkRTPPrx sink = StreamSinkRTPPrx::checkedCast((*i));
+
+ /* No, these are not accidentally reversed. We want to try to set an IPv4 address
+ * on an IPv6 sink and vice versa to make sure that an exception does get thrown.
+ */
+#ifdef IPV6_TEST
+ sink->setRemoteDetails("127.0.0.1", 10000);
+#else
+ sink->setRemoteDetails("::1", 10000);
+#endif
+
+ set = true;
+ }
+ }
+ catch (const Ice::Exception &e)
+ {
+ BOOST_TEST_MESSAGE(e.ice_name());
+ BOOST_TEST_MESSAGE(e.what());
+ }
+ catch (...)
+ {
+ }
+
+ BOOST_CHECK(!set);
+}
+
+/**
* Attempt to release our RTP session
*/
BOOST_AUTO_TEST_CASE(ReleaseRTPSession)
-----------------------------------------------------------------------
--
asterisk-scf/release/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list