[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 09:22:42 CDT 2010


branch "master" has been updated
       via  025ec1c1d97657a483ee73448054e3d2ed2f96eb (commit)
       via  1938c0e01bef538c7c924dc8ca0701c6145241d4 (commit)
      from  e827dc5fdad977467f6f8a495ebad2d1bd856bb2 (commit)

Summary of changes:
 test/TestRTPpjmedia.cpp |  147 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 110 insertions(+), 37 deletions(-)


- Log -----------------------------------------------------------------
commit 025ec1c1d97657a483ee73448054e3d2ed2f96eb
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 11:34:40 2010 -0300

    Add a payload to the test frame, wait for it to get sent/received, and then confirm the frame received matches the frame sent.

diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index 5eba667..435aeb6 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -26,8 +26,44 @@ public:
 static ArgCacheType mCachedArgs;
 
 /**
- * Basic implementation of a media sink, for frames received from the RTP session.
+ * 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.
  */
+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;
+};
+static SharedTestData Testbed;
+
 class TestStreamSink : public StreamSink
 {
 public:
@@ -36,7 +72,7 @@ public:
 	 */
 	void write(const Hydra::Media::V1::FrameSeq& frames, const Ice::Current&)
 	{
-		cout << "Got " << frames.size() << " frames" << endl;
+		Testbed.frames = frames;
 	}
 
 	/**
@@ -79,40 +115,6 @@ private:
 };
 
 /**
- * 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.
- */
-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;
-};
-static SharedTestData Testbed;
-
-/**
  * A global fixture for Ice initialization.
  * Provides setup/teardown for the entire set of tests.
  */
@@ -452,8 +454,9 @@ BOOST_AUTO_TEST_CASE(PushPayloadMappings)
 	try
 	{
 		/* Create a dummy format for our media */
-		FormatPtr format = new Format();
+		AudioFormatPtr format = new AudioFormat();
 		format->name = "test_format";
+		format->frameSize = 20;
 
 		/* I'm just going to go ahead and use payload 98 for it since
 		 * that is dynamic.
@@ -530,12 +533,44 @@ BOOST_AUTO_TEST_CASE(TransmitandReceiveFrame)
 		AudioFramePtr frame = new AudioFrame();
 		frame->mediaformat = format;
 
+		/* Populate the payload with some useless data, but even to confirm the payload passes unaltered. */
+		frame->payload.push_back('a');
+		frame->payload.push_back('b');
+                frame->payload.push_back('c');
+		frame->payload.push_back('d');
+		frame->payload.push_back('e');
+		frame->payload.push_back('f');
+		frame->payload.push_back('g');
+		frame->payload.push_back('h');
+		frame->payload.push_back('i');
+		frame->payload.push_back('j');
+
 		FrameSeq frames;
 		frames.push_back(frame);
 
 		StreamSinkSeq sinks = Testbed.session->getSinks();
 		StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
 		sink->write(frames);
+
+		/* In order to have the packet get sent and received we need to introduce a delay here, thus
+		 * why it exists.
+		 */
+		sleep(1);
+
+		/* We only sent a single frame, so we should only get a single frame. */
+		AudioFramePtr received_frame;
+		if (Testbed.frames.size() == 1 &&
+		    (received_frame = AudioFramePtr::dynamicCast(Testbed.frames.front())) &&
+		    (received_frame->mediaformat->name == format->name))
+		{
+			AudioFormatPtr received_format;
+			if ((received_format = AudioFormatPtr::dynamicCast(received_frame->mediaformat)) &&
+			    (received_format->frameSize == format->frameSize) &&
+			    (received_frame->payload == frame->payload))
+			{
+				received = true;
+			}
+		}
 	}
 	catch (const Ice::Exception &e)
 	{

commit 1938c0e01bef538c7c924dc8ca0701c6145241d4
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Aug 18 10:43:48 2010 -0300

    Add a test for actual media transmission and reception.

diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index b1c80d4..5eba667 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -36,6 +36,7 @@ public:
 	 */
 	void write(const Hydra::Media::V1::FrameSeq& frames, const Ice::Current&)
 	{
+		cout << "Got " << frames.size() << " frames" << endl;
 	}
 
 	/**
@@ -220,8 +221,9 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
 
 		RTPMediaServicePrx service = RTPMediaServicePrx::uncheckedCast(Testbed.locator->locate(params));
 
-		FormatPtr format = new Format();
+		AudioFormatPtr format = new AudioFormat();
 		format->name = "test_format";
+		format->frameSize = 20;
 
 		FormatSeq formats;
 		formats.push_back(format);
@@ -512,6 +514,42 @@ BOOST_AUTO_TEST_CASE(SetupLoopback)
 }
 
 /**
+ * Actually write a frame out, have it get transmitted via RTP, received via RTP,
+ * and then transmogrified back into a frame and written to our sink.
+ */
+BOOST_AUTO_TEST_CASE(TransmitandReceiveFrame)
+{
+	bool received = false;
+
+	try
+	{
+		AudioFormatPtr format = new AudioFormat();
+		format->name = "test_format";
+		format->frameSize = 20;
+
+		AudioFramePtr frame = new AudioFrame();
+		frame->mediaformat = format;
+
+		FrameSeq frames;
+		frames.push_back(frame);
+
+		StreamSinkSeq sinks = Testbed.session->getSinks();
+		StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
+		sink->write(frames);
+	}
+	catch (const Ice::Exception &e)
+	{
+		BOOST_TEST_MESSAGE(e.ice_name());
+		BOOST_TEST_MESSAGE(e.what());
+	}
+	catch (...)
+	{
+	}
+
+	BOOST_CHECK(received);
+}
+
+/**
  * 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