[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
Wed Aug 18 08:18:31 CDT 2010


branch "master" has been updated
       via  e827dc5fdad977467f6f8a495ebad2d1bd856bb2 (commit)
       via  8b8c4a2ea7e2106741029c8d3fdcb525c130e147 (commit)
       via  65605673ed02899aace8be6721beab5732efe8f2 (commit)
       via  bb508de3f2eba259ce741748a0d9b726c40d4df7 (commit)
       via  6f005cc362afa22d075db0b48a12dc84804f1d62 (commit)
      from  baf590492af8bb988f0cd537101390bec9d1ba78 (commit)

Summary of changes:
 src/RTPSink.cpp         |   24 +++++-
 src/RTPSource.cpp       |    3 +
 test/TestRTPpjmedia.cpp |  213 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+), 3 deletions(-)


- Log -----------------------------------------------------------------
commit e827dc5fdad977467f6f8a495ebad2d1bd856bb2
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 10:26:01 2010 -0300

    More tests! Confirm that setting the sink works properly, and also proceed on getting loopback setup.

diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index c9b5079..b1c80d4 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -404,6 +404,114 @@ BOOST_AUTO_TEST_CASE(ConfirmRemoteAddressSetting)
 }
 
 /**
+ * Check that we can change the sink on the source
+ */
+BOOST_AUTO_TEST_CASE(ConfirmSinkSetting)
+{
+	bool set = false;
+
+        try
+	{
+		StreamSourceSeq sources = Testbed.session->getSources();
+
+		for (StreamSourceSeq::const_iterator i = sources.begin(); i != sources.end(); ++i)
+		{
+			StreamSourceRTPPrx source = StreamSourceRTPPrx::checkedCast((*i));
+
+			source->setSink(Testbed.sink);
+
+			StreamSinkPrx sink = source->getSink();
+
+			if (Testbed.sink == sink)
+			{
+				set = true;
+			}
+		}
+	}
+	catch (const Ice::Exception &e)
+	{
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	}
+	catch (...)
+	{
+	}
+
+	BOOST_CHECK(set);
+}
+
+/**
+ * Push payload information out to the session
+ */
+BOOST_AUTO_TEST_CASE(PushPayloadMappings)
+{
+	bool pushed = false;
+
+	try
+	{
+		/* Create a dummy format for our media */
+		FormatPtr format = new Format();
+		format->name = "test_format";
+
+		/* I'm just going to go ahead and use payload 98 for it since
+		 * that is dynamic.
+		 */
+		PayloadMap mapping;
+		mapping.insert(make_pair(98, format));
+
+		Testbed.session->associatePayloads(mapping);
+
+		pushed = true;
+	}
+	catch (const Ice::Exception &e)
+	{
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	}
+	catch (...)
+	{
+	}
+
+	BOOST_CHECK(pushed);
+}
+
+/**
+ * Setup RTP loopback from the session to, well, the session
+ */
+BOOST_AUTO_TEST_CASE(SetupLoopback)
+{
+	bool looped = false;
+
+	try
+	{
+		/* By grabbing the local address information of the source we can connect it to the sink and, in theory,
+		 * have media flow.
+		 */
+		StreamSourceSeq sources = Testbed.session->getSources();
+		StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());
+		string address = source->getLocalAddress();
+		int port = source->getLocalPort();
+
+		/* Okay, changing the remote details of the first sink should have it send media to the above. */
+		StreamSinkSeq sinks = Testbed.session->getSinks();
+		StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
+		sink->setRemoteDetails(address, port);
+
+		looped = true;
+	}
+	catch (const Ice::Exception &e)
+	{
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	}
+	catch (...)
+	{
+	}
+
+	BOOST_CHECK(looped);
+}
+
+/**
  * Attempt to release our RTP session
  */
 BOOST_AUTO_TEST_CASE(ReleaseRTPSession)

commit 8b8c4a2ea7e2106741029c8d3fdcb525c130e147
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 10:25:25 2010 -0300

    Fix a bug where changing remote details after already changing them caused insanity.

diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 609dd43..6e98cbc 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -205,6 +205,9 @@ void StreamSourceRTPImpl::setRemoteDetails(std::string address, int 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);
+
 	/* All ready... actually do it! */
 	pj_status_t status = pjmedia_transport_attach(mImpl->mSession->getTransport(), this, &sin, NULL, sizeof(pj_sockaddr_in), &receiveRTP, NULL);
 

commit 65605673ed02899aace8be6721beab5732efe8f2
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 10:04:59 2010 -0300

    Add a test media sink for testing actual media flow.

diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index f92edd2..c9b5079 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -26,6 +26,58 @@ public:
 static ArgCacheType mCachedArgs;
 
 /**
+ * Basic implementation of a media sink, for frames received from the RTP session.
+ */
+class TestStreamSink : public StreamSink
+{
+public:
+	/**
+	 * Implementation of the write method which doesn't really do anything yet.
+	 */
+	void write(const Hydra::Media::V1::FrameSeq& frames, const Ice::Current&)
+	{
+	}
+
+	/**
+	 * Implementation of the setSource method which just stores the source away for later retrieval.
+	 */
+	void setSource(const Hydra::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;
+};
+
+/**
  * It seems odd that boost doesn't provide an easy way to access the GLOBAL_FIXTURE members.
  * But it doesn't seem to, so I'm sharing global setup stuff here.
  */
@@ -46,6 +98,16 @@ public:
 	 * 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;
 };
 static SharedTestData Testbed;
 
@@ -67,6 +129,14 @@ struct GlobalIceFixture
 				{
 					Testbed.communicator = Ice::initialize(mCachedArgs.argc, mCachedArgs.argv);
 
+					Testbed.adapter = Testbed.communicator->createObjectAdapterWithEndpoints("SinkAdapter", "default");
+
+					StreamSinkPtr sink = new TestStreamSink();
+
+					Testbed.sink = StreamSinkPrx::uncheckedCast(Testbed.adapter->addWithUUID(sink));
+
+					Testbed.adapter->activate();
+
 					Testbed.locator = ServiceLocatorPrx::checkedCast(Testbed.communicator->stringToProxy("LocatorService:tcp -p 2657"));
 
 					if (!Testbed.locator) {

commit bb508de3f2eba259ce741748a0d9b726c40d4df7
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 09:51:21 2010 -0300

    Store the set remote address/port for when we are queried for it before media is received. This doesn't seem to be accessible in pjmedia.

diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 06b0ea4..e53796b 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -41,7 +41,7 @@ public:
 	/**
 	 * Constructor for our StreamSinkRTPImplPriv class.
 	 */
-	StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session) { pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand()); };
+	StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mRemotePort(0) { pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand()); };
 
 	/**
 	 * A structure containing outgoing pjmedia session data.
@@ -57,6 +57,16 @@ public:
 	 * 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;
 };
 
 /**
@@ -156,6 +166,12 @@ void StreamSinkRTPImpl::setRemoteDetails(const std::string& address, Ice::Int po
 	 * 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;
 }
 
 /**
@@ -168,7 +184,8 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
 	pjmedia_transport_info_init(&transportInfo);
 	pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
 
-	return pj_inet_ntoa(transportInfo.src_rtp_name.ipv4.sin_addr);
+	string address = pj_inet_ntoa(transportInfo.src_rtp_name.ipv4.sin_addr);
+	return (address != "0.0.0.0") ? address : mImpl->mRemoteAddress;
 }
 
 /**
@@ -181,5 +198,6 @@ Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
 	pjmedia_transport_info_init(&transportInfo);
 	pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
 
-	return pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
+	int port = pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
+	return (port != 0) ? port : mImpl->mRemotePort;
 }

commit 6f005cc362afa22d075db0b48a12dc84804f1d62
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 09:25:57 2010 -0300

    Add a test confirming we can set remote address details.

diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 40c315f..f92edd2 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -299,6 +299,41 @@ BOOST_AUTO_TEST_CASE(ConfirmBlankRemoteAddressonSinks)
 }
 
 /**
+ * Check that we can set the remote address information properly
+ */
+BOOST_AUTO_TEST_CASE(ConfirmRemoteAddressSetting)
+{
+	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));
+
+			sink->setRemoteDetails("127.0.0.1", 10000);
+
+			if (sink->getRemoteAddress() == "127.0.0.1" && sink->getRemotePort() == 10000)
+			{
+				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/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list