[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
Tue Aug 17 20:17:55 CDT 2010


branch "master" has been updated
       via  f781c7e7756a7d39123dc488888944550e54c82f (commit)
      from  74626ffec894fe58322e576ce6b1e49cd5432ecb (commit)

Summary of changes:
 src/MediaRTPpjmedia.cpp |   54 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit f781c7e7756a7d39123dc488888944550e54c82f
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 17 22:30:21 2010 -0300

    Add an ICE thread notification hook which allows us to register threads with pjlib (as that is required).

diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 26256d6..d9006d5 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -21,6 +21,8 @@
 #include <pjlib.h>
 #include <pjmedia.h>
 
+#include <boost/shared_ptr.hpp>
+
 #include "Core/Discovery/ServiceLocatorIf.h"
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
@@ -70,13 +72,63 @@ private:
 };
 
 /**
+ * Wrapper class around pj_thread_desc.
+ */
+class ThreadDescWrapper
+{
+public:
+	/**
+	 * pjthread thread description information, must persist for the life of the thread
+	 */
+	pj_thread_desc mDesc;
+};
+
+/**
+ * Type definition used to create a smart pointer for the above.
+ */
+typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
+
+/**
+ * Implementation of the Ice::ThreadNotification class.
+ */
+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()
+	{
+		pjThreads.erase(pj_thread_this());
+	}
+private:
+	/**
+	 * A map containing thread lifetime persistent data.
+	 */
+	map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
+};
+
+/**
  * Main entry point for our pjmedia rtp component.
  */
 int main(int argc, char* argv[])
 {
 	MediaRTPpjmediaApp app;
 	app.callbackOnInterrupt();
-	return app.main(argc, argv);
+	Ice::InitializationData id;
+	id.threadHook = new pjlibHook();
+	return app.main(argc, argv, id);
 }
 
 /**

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list