[hydra-commits] hydra/media_rtp_pjmedia.git branch "master" updated.

Commits to the Hydra project code repositories hydra-commits at lists.digium.com
Sun Aug 15 15:49:02 CDT 2010


branch "master" has been updated
       via  445f160c9a64c9f94ad2a0b52f8e3d19213f0a58 (commit)
       via  0dd34e63864607e2473d64017c9e5adb22d01e11 (commit)
       via  70f1a674d17702cc20f3579a4368b9aec31342f3 (commit)
       via  cb09d54dab02733836391b37e552599df5ce745e (commit)
      from  50d69d0d746cc512941c7af89e04312978204fcd (commit)

Summary of changes:
 pjproject.cmake    |    4 ++
 slice              |    2 +-
 src/RTPSession.cpp |   10 +++++-
 src/RTPSession.h   |    1 +
 src/RTPSink.cpp    |   83 ++++++++++++++++++++++++++++++++++++++++++++-------
 src/RTPSink.h      |    3 +-
 src/RTPSource.cpp  |    7 ++++
 src/RTPSource.h    |    6 ++++
 8 files changed, 100 insertions(+), 16 deletions(-)


- Log -----------------------------------------------------------------
commit 445f160c9a64c9f94ad2a0b52f8e3d19213f0a58
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Aug 15 18:03:56 2010 -0300

    setRemoteDetails now gets into SourceRTPImpl. Next step is to attach the transport.

diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index cff4f98..82fc159 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -70,7 +70,7 @@ public:
 	/**
 	 * A stream source for this RTP session.
 	 */
-	StreamSourceRTPPtr mStreamSource;
+	StreamSourceRTPImplPtr mStreamSource;
 
 	/**
 	 * A proxy to the above mentioned stream source.
@@ -216,4 +216,5 @@ FormatSeq RTPSessionImpl::getFormats()
  */
 void RTPSessionImpl::setRemoteDetails(std::string address, int port)
 {
+	mImpl->mStreamSource->setRemoteDetails(address, port);
 }
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index c104898..60e9ba0 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -133,3 +133,10 @@ Ice::Int StreamSourceRTPImpl::getLocalPort(const Ice::Current&)
 
 	return pj_ntohs(transportInfo.sock_info.rtp_addr_name.ipv4.sin_port);
 }
+
+/**
+ * API call which sets up our pjmedia transport and allows media to be sent and received.
+ */
+void StreamSourceRTPImpl::setRemoteDetails(std::string address, int port)
+{
+}
diff --git a/src/RTPSource.h b/src/RTPSource.h
index 446a7d7..5d372c3 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -46,3 +46,8 @@ private:
 	 */
 	boost::shared_ptr<StreamSourceRTPImplPriv> mImpl;
 };
+
+/**
+ * A typedef which creates a smart pointer type for StreamSourceRTPImpl.
+ */
+typedef IceUtil::Handle<StreamSourceRTPImpl> StreamSourceRTPImplPtr;

commit 0dd34e63864607e2473d64017c9e5adb22d01e11
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Aug 15 17:47:45 2010 -0300

    Begin the process of passing through setup of the transport to RTPSourceImpl.

diff --git a/slice b/slice
index b5f6c63..49fdc43 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit b5f6c63f2ba9da7a94a3aea8affa6796de36dbea
+Subproject commit 49fdc431aec2f9335f386125e76ea2ab77802187
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 069628c..cff4f98 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -210,3 +210,10 @@ FormatSeq RTPSessionImpl::getFormats()
 {
 	return mImpl->mFormats;
 }
+
+/**
+ * API call which calls into RTPSourceImpl in order to setup transport.
+ */
+void RTPSessionImpl::setRemoteDetails(std::string address, int port)
+{
+}
diff --git a/src/RTPSession.h b/src/RTPSession.h
index 9ea05bb..43c5d99 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -41,6 +41,7 @@ public:
 	Hydra::Media::RTP::V1::RTPSessionPrx getProxy();
 	pjmedia_transport* getTransport();
 	Hydra::Media::V1::FormatSeq getFormats();
+	void setRemoteDetails(std::string address, int port);
 private:
 	/**
 	 * Private implementation data for RTPSessionImpl.
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index fc2da17..4ffec57 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -159,35 +159,14 @@ std::string StreamSinkRTPImpl::getId(const Ice::Current& current)
 }
 
 /**
- * Implementation of the setRemoteAddress method as defined in MediaRTPIf.ice
+ * Implementation of the setRemoteDetails method as defined in MediaRTPIf.ice
  */
-void StreamSinkRTPImpl::setRemoteAddress(const std::string& address, const Ice::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->mRemoteAddress = address;
-
-	/* If we also have the port we can go ahead and talk to RTPSourceImpl. */
-	if (mImpl->mRemotePort)
-	{
-	}
-}
-
-/**
- * Implementation of the setRemotePort method as defined in MediaRTPIf.ice
- */
-void StreamSinkRTPImpl::setRemotePort(Ice::Int port, const Ice::Current&)
-{
-	/* This method is essentially a passthru to the RTPSourceImpl. It takes care of
-	 * actually attaching the transport.
-	 */
-	mImpl->mRemotePort = port;
-
-	/* If we also have the address we can go ahead and talk to RTPSourceImpl. */
-	if (!mImpl->mRemoteAddress.empty())
-	{
-	}
+	mImpl->mSession->setRemoteDetails(address, port);
 }
 
 /**
diff --git a/src/RTPSink.h b/src/RTPSink.h
index 99d0406..e026b93 100644
--- a/src/RTPSink.h
+++ b/src/RTPSink.h
@@ -37,8 +37,7 @@ public:
 	Hydra::Media::V1::StreamSourcePrx getSource(const Ice::Current&);
 	Hydra::Media::V1::FormatSeq getFormats(const Ice::Current&);
 	std::string getId(const Ice::Current&);
-	void setRemoteAddress(const std::string&, const Ice::Current&);
-	void setRemotePort(Ice::Int, 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:
diff --git a/src/RTPSource.h b/src/RTPSource.h
index f5f6f3d..446a7d7 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -39,6 +39,7 @@ public:
 	void requestFormat(const Hydra::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:
 	/**
 	 * Private implementation data for StreamSourceRTPImpl.

commit 70f1a674d17702cc20f3579a4368b9aec31342f3
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Aug 15 17:39:11 2010 -0300

    Add more implementation of the StreamSinkRTP interface. It should now construct the RTP header and send it out, but is not yet copying the payload or setting the remote address details.

diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index f39427f..fc2da17 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -57,6 +57,18 @@ public:
 	 * A proxy to the sink that we are receiving media from.
 	 */
 	StreamSourcePrx mSource;
+
+	/**
+	 * Temporary storage for remote address, used while waiting for port
+	 * to be populated.
+	 */
+	string mRemoteAddress;
+
+	/**
+	 * Temporary storage for remote port, used while waiting for address
+	 * to be populated.
+	 */
+        int mRemotePort;
 };
 
 /**
@@ -69,8 +81,48 @@ StreamSinkRTPImpl::StreamSinkRTPImpl(RTPSessionImplPtr session) : mImpl(new Stre
 /**
  * Implementation of the write method as defined in MediaIf.ice
  */
-void StreamSinkRTPImpl::write(const Hydra::Media::V1::FrameSeq&, const Ice::Current&)
+void StreamSinkRTPImpl::write(const Hydra::Media::V1::FrameSeq& frames, const Ice::Current&)
 {
+	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;
+
+		/* Using the available information construct an RTP header that we can place at the front of our packet */
+		/* TODO: We need to be able to set the RTP payload value here, from the frame? otherwise? */
+		pj_status_t status = pjmedia_rtp_encode_rtp(&mImpl->mOutgoingSession, 0, 0, (*frame)->payload.size(), audioformat->frameSize, &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[(*frame)->payload.size() + header_len];
+
+		/* Copy the header itself that we produced in */
+		pj_memcpy(packet, (const pjmedia_rtp_hdr*)header, header_len);
+
+		/* Now the actual payload */
+
+		/* 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;
+		}
+	}
 }
 
 /**
@@ -109,15 +161,33 @@ std::string StreamSinkRTPImpl::getId(const Ice::Current& current)
 /**
  * Implementation of the setRemoteAddress method as defined in MediaRTPIf.ice
  */
-void StreamSinkRTPImpl::setRemoteAddress(const std::string&, const Ice::Current&)
+void StreamSinkRTPImpl::setRemoteAddress(const std::string& address, const Ice::Current&)
 {
+	/* This method is essentially a passthru to the RTPSourceImpl. It takes care of
+	 * actually attaching the transport.
+	 */
+	mImpl->mRemoteAddress = address;
+
+	/* If we also have the port we can go ahead and talk to RTPSourceImpl. */
+	if (mImpl->mRemotePort)
+	{
+	}
 }
 
 /**
  * Implementation of the setRemotePort method as defined in MediaRTPIf.ice
  */
-void StreamSinkRTPImpl::setRemotePort(Ice::Int, const Ice::Current&)
+void StreamSinkRTPImpl::setRemotePort(Ice::Int port, const Ice::Current&)
 {
+	/* This method is essentially a passthru to the RTPSourceImpl. It takes care of
+	 * actually attaching the transport.
+	 */
+	mImpl->mRemotePort = port;
+
+	/* If we also have the address we can go ahead and talk to RTPSourceImpl. */
+	if (!mImpl->mRemoteAddress.empty())
+	{
+	}
 }
 
 /**
@@ -125,7 +195,12 @@ void StreamSinkRTPImpl::setRemotePort(Ice::Int, const Ice::Current&)
  */
 std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
 {
-	return "bob";
+	pjmedia_transport_info transportInfo;
+
+	pjmedia_transport_info_init(&transportInfo);
+	pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+
+	return pj_inet_ntoa(transportInfo.src_rtp_name.ipv4.sin_addr);
 }
 
 /**
@@ -133,5 +208,10 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
  */
 Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
 {
-	return 5060;
+	pjmedia_transport_info transportInfo;
+
+	pjmedia_transport_info_init(&transportInfo);
+	pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
+
+	return pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
 }

commit cb09d54dab02733836391b37e552599df5ce745e
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Aug 15 17:03:31 2010 -0300

    Get linking against pjmedia working.

diff --git a/pjproject.cmake b/pjproject.cmake
index 5856787..e7cf1e0 100644
--- a/pjproject.cmake
+++ b/pjproject.cmake
@@ -25,6 +25,9 @@ function(pjproject_build PJPROJECT_COMPONENT)
   else()
     message(STATUS "Unfortunately you are building on a platform which does not support automatic pjproject building. You will have to build pjproject manually.")
   endif()
+  if (${PJPROJECT_COMPONENT} STREQUAL "pjmedia")
+    link_directories("${CMAKE_SOURCE_DIR}/pjproject/third_party/lib")
+  endif()
   include_directories("${CMAKE_SOURCE_DIR}/pjproject/${PJPROJECT_COMPONENT}/include")
   link_directories("${CMAKE_SOURCE_DIR}/pjproject/${PJPROJECT_COMPONENT}/lib")
 endfunction()
@@ -46,6 +49,7 @@ function(pjproject_link COMPONENT PJPROJECT_COMPONENT)
       target_link_libraries(${COMPONENT} "pjmedia-codec-asteriskscf")
       target_link_libraries(${COMPONENT} "pjsdp-asteriskscf")
       target_link_libraries(${COMPONENT} "pjmedia-audiodev-asteriskscf")
+      target_link_libraries(${COMPONENT} "srtp-asteriskscf")
     else()
       target_link_libraries(${COMPONENT} "${PJPROJECT_COMPONENT}-asteriskscf")
     endif()

-----------------------------------------------------------------------


-- 
hydra/media_rtp_pjmedia.git




More information about the asterisk-scf-commits mailing list