[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "replication" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Dec 8 09:31:02 CST 2010


branch "replication" has been updated
       via  1d3fefe487649815ea6ee8893a5069bf53f06193 (commit)
      from  7eacee9b505a41ed7e853abb2649e36edb5f75b8 (commit)

Summary of changes:
 src/RTPSession.cpp |   30 +++++++++++++++++++++---------
 src/RTPSession.h   |   10 ++++++++++
 src/RTPSink.cpp    |   46 ++++++++++++++++++++++++++--------------------
 src/RTPSink.h      |    1 +
 src/RTPSource.cpp  |   27 ++++++++++++++++++++-------
 src/RTPSource.h    |    1 +
 6 files changed, 79 insertions(+), 36 deletions(-)


- Log -----------------------------------------------------------------
commit 1d3fefe487649815ea6ee8893a5069bf53f06193
Author: Joshua Colp <jcolp at digium.com>
Date:   Wed Dec 8 11:30:19 2010 -0400

    Populate state items and get them ready for replicating.

diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 657a3a9..d2163ad 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -15,12 +15,14 @@
  */
 
 #include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
 
 #include <pjlib.h>
 #include <pjmedia.h>
 
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
+#include "RtpStateReplicationIf.h"
 
 #include "RTPSession.h"
 #include "RTPSource.h"
@@ -47,7 +49,7 @@ using namespace AsteriskSCF::Media::RTP::V1;
 class RTPSessionImplPriv
 {
 public:
-    RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats) : mAdapter(adapter), mFormats(formats) { };
+    RTPSessionImplPriv(Ice::ObjectAdapterPtr adapter, const FormatSeq& formats) : mAdapter(adapter), mFormats(formats), mSessionStateItem(new RtpSessionStateItem()) { };
     ~RTPSessionImplPriv();
 
     /**
@@ -88,7 +90,7 @@ public:
     /**
      * A stream sink for this RTP session.
      */
-    StreamSinkRTPPtr mStreamSink;
+    StreamSinkRTPImplPtr mStreamSink;
 
     /**
      * A proxy to the above mentioned stream sink.
@@ -96,14 +98,14 @@ public:
     StreamSinkRTPPrx mStreamSinkProxy;
 
     /**
-     * A dictionary mapping payloads to media formats.
+     * A dictionary mapping media formats to payloads.
      */
-    PayloadMap mPayloadstoFormats;
+    map<string, int> mFormatstoPayloads;
 
     /**
-     * A dictionary mapping media formats to payloads.
+     * Session state item.
      */
-    map<string, int> mFormatstoPayloads;
+    RtpSessionStateItemPtr mSessionStateItem;
 };
 
 /**
@@ -127,17 +129,27 @@ RTPSessionImpl::RTPSessionImpl(Ice::ObjectAdapterPtr adapter, const FormatSeq& f
     {
         if ((status = pjmedia_transport_udp_create2(mImpl->mEndpoint, "RTP", NULL, port, 0, &mImpl->mTransport)) == PJ_SUCCESS)
         {
+	    mImpl->mSessionStateItem->mPort = port;
             break;
         }
     }
 
+    // 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;
+
     /* First up for our own stuff is... a source! Media needs to come from somewhere, you know. */
     mImpl->mStreamSource = new StreamSourceRTPImpl(this);
     mImpl->mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSource));
+    mImpl->mSessionStateItem->mSourceIdentity = mImpl->mStreamSourceProxy->ice_getIdentity();
 
     /* And for my next trick a place for us to send media out. */
     mImpl->mStreamSink = new StreamSinkRTPImpl(this);
     mImpl->mStreamSinkProxy = StreamSinkRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSink));
+    mImpl->mSessionStateItem->mSinkIdentity = mImpl->mStreamSinkProxy->ice_getIdentity();
+
+    // TODO: Send out replication update for session, source, and sink
 }
 
 /**
@@ -254,7 +266,7 @@ void RTPSessionImpl::release(const Ice::Current&)
  */
 void RTPSessionImpl::associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap& mappings, const Ice::Current&)
 {
-    mImpl->mPayloadstoFormats = mappings;
+    mImpl->mSessionStateItem->mPayloadstoFormats = mappings;
 
     for (PayloadMap::const_iterator it = mappings.begin(); it != mappings.end(); ++it)
     {
@@ -307,9 +319,9 @@ void RTPSessionImpl::setRemoteDetails(std::string address, int port)
  */
 FormatPtr RTPSessionImpl::getFormat(int payload)
 {
-    PayloadMap::iterator it = mImpl->mPayloadstoFormats.find(payload);
+    PayloadMap::iterator it = mImpl->mSessionStateItem->mPayloadstoFormats.find(payload);
 
-    if (it == mImpl->mPayloadstoFormats.end())
+    if (it == mImpl->mSessionStateItem->mPayloadstoFormats.end())
     {
         return 0;
     }
diff --git a/src/RTPSession.h b/src/RTPSession.h
index 5a72f8b..2b72c0b 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -16,6 +16,16 @@
 class RTPSessionImplPriv;
 
 /**
+ * Forward definition for our private implementation of StreamSinkRTP.
+ */
+class StreamSinkRTPImpl;
+
+/**
+ * A typedef which creates a smart pointer type for StreamSinkRTPImpl.
+ */
+typedef IceUtil::Handle<StreamSinkRTPImpl> StreamSinkRTPImplPtr;
+
+/**
  * Forward definition for our private implementation of StreamSourceRTP.
  */
 class StreamSourceRTPImpl;
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 3e80164..c30e611 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -15,12 +15,14 @@
  */
 
 #include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
 
 #include <pjlib.h>
 #include <pjmedia.h>
 
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
+#include "RtpStateReplicationIf.h"
 
 #include "RTPSession.h"
 #include "RTPSink.h"
@@ -39,7 +41,7 @@ public:
     /**
      * Constructor for our StreamSinkRTPImplPriv class.
      */
-    StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mRemotePort(0) { pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand()); };
+    StreamSinkRTPImplPriv(RTPSessionImplPtr);
 
     /**
      * A structure containing outgoing pjmedia session data.
@@ -52,19 +54,19 @@ public:
     RTPSessionImplPtr mSession;
 
     /**
-     * A proxy to the sink that we are receiving media from.
+     * Stream sink state item.
      */
-    StreamSourcePrx mSource;
-
-    /**
-     * The IP address that we are configured to send media to.
-     */
-    string mRemoteAddress;
+    RtpStreamSinkStateItemPtr mSinkStateItem;
+};
 
-    /**
-     * The port that we are configured to send media to.
-     */
-    int mRemotePort;
+/**
+ * Constructor for the StreamSinkRTPImplPriv class.
+ */
+StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mSinkStateItem(new RtpStreamSinkStateItem())
+{
+    pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand());
+    mSinkStateItem->key = IceUtil::generateUUID();
+    mSinkStateItem->mRemotePort = 0;
 };
 
 /**
@@ -80,7 +82,7 @@ StreamSinkRTPImpl::StreamSinkRTPImpl(RTPSessionImplPtr session) : mImpl(new Stre
 void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
 {
     // Don't even bother if no remote address information is present
-    if (mImpl->mRemoteAddress.empty() || !mImpl->mRemotePort)
+    if (mImpl->mSinkStateItem->mRemoteAddress.empty() || !mImpl->mSinkStateItem->mRemotePort)
     {
         return;
     }
@@ -140,7 +142,9 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
  */
 void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
 {
-    mImpl->mSource = source;
+    mImpl->mSinkStateItem->mSource = source;
+
+    // TODO: Send state item off for replication
 }
 
 /**
@@ -148,7 +152,7 @@ void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&
  */
 AsteriskSCF::Media::V1::StreamSourcePrx StreamSinkRTPImpl::getSource(const Ice::Current&)
 {
-    return mImpl->mSource;
+    return mImpl->mSinkStateItem->mSource;
 }
 
 /**
@@ -179,10 +183,12 @@ void StreamSinkRTPImpl::setRemoteDetails(const std::string& address, Ice::Int po
     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.
+     * are asked for the remote address. It is also stored for replication purposes.
      */
-    mImpl->mRemoteAddress = address;
-    mImpl->mRemotePort = port;
+    mImpl->mSinkStateItem->mRemoteAddress = address;
+    mImpl->mSinkStateItem->mRemotePort = port;
+
+    // TODO: Send state item off for replication
 }
 
 /**
@@ -196,7 +202,7 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
     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->mRemoteAddress;
+    return (address != "0.0.0.0") ? address : mImpl->mSinkStateItem->mRemoteAddress;
 }
 
 /**
@@ -210,5 +216,5 @@ Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
     pjmedia_transport_get_info(mImpl->mSession->getTransport(), &transportInfo);
 
     int port = pj_ntohs(transportInfo.src_rtp_name.ipv4.sin_port);
-    return (port != 0) ? port : mImpl->mRemotePort;
+    return (port != 0) ? port : mImpl->mSinkStateItem->mRemotePort;
 }
diff --git a/src/RTPSink.h b/src/RTPSink.h
index 81562ab..cf5c114 100644
--- a/src/RTPSink.h
+++ b/src/RTPSink.h
@@ -30,6 +30,7 @@ public:
     void setRemoteDetails(const std::string&, Ice::Int, const Ice::Current&);
     std::string getRemoteAddress(const Ice::Current&);
     Ice::Int getRemotePort(const Ice::Current&);
+    AsteriskSCF::Media::RTP::V1::RtpStreamSinkStateItemPtr getStateItem();
 private:
     /**
      * Private implementation data for StreamSinkRTPImpl.
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index e25aaf0..8929c0d 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -15,12 +15,14 @@
  */
 
 #include <Ice/Ice.h>
+#include <IceUtil/UUID.h>
 
 #include <pjlib.h>
 #include <pjmedia.h>
 
 #include "Media/MediaIf.h"
 #include "Media/RTP/MediaRTPIf.h"
+#include "RtpStateReplicationIf.h"
 
 #include "RTPSession.h"
 #include "RTPSource.h"
@@ -46,7 +48,7 @@ public:
     /**
      * Constructor for our StreamSourceRTPImplPriv class.
      */
-    StreamSourceRTPImplPriv(RTPSessionImplPtr session) : mSession(session) { pjmedia_rtp_session_init(&mIncomingSession, 0, 0); };
+    StreamSourceRTPImplPriv(RTPSessionImplPtr);
 
     /**
      * A structure containing incoming pjmedia session data.
@@ -59,9 +61,18 @@ public:
     RTPSessionImplPtr mSession;
 
     /**
-     * A proxy to the sink that we are writing incoming media to.
+     * Stream source state item.
      */
-    StreamSinkPrx mSink;
+    RtpStreamSourceStateItemPtr mSourceStateItem;
+};
+
+/**
+ * Constructor for the StreamSourceRTPImplPriv class.
+ */
+StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(RTPSessionImplPtr session) : mSession(session), mSourceStateItem(new RtpStreamSourceStateItem())
+{
+    pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
+    mSourceStateItem->key = IceUtil::generateUUID();
 };
 
 /**
@@ -76,7 +87,9 @@ StreamSourceRTPImpl::StreamSourceRTPImpl(RTPSessionImplPtr session) : mImpl(new
  */
 void StreamSourceRTPImpl::setSink(const AsteriskSCF::Media::V1::StreamSinkPrx& sink, const Ice::Current&)
 {
-    mImpl->mSink = sink;
+    mImpl->mSourceStateItem->mSink = sink;
+
+    // TODO: Send off for replication
 }
 
 /**
@@ -84,7 +97,7 @@ void StreamSourceRTPImpl::setSink(const AsteriskSCF::Media::V1::StreamSinkPrx& s
  */
 AsteriskSCF::Media::V1::StreamSinkPrx StreamSourceRTPImpl::getSink(const Ice::Current&)
 {
-    return mImpl->mSink;
+    return mImpl->mSourceStateItem->mSink;
 }
 
 /**
@@ -165,7 +178,7 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
         return;
     }
 
-    if (source->mImpl->mSink != 0)
+    if (source->mImpl->mSourceStateItem->mSink != 0)
     {
         FormatPtr mediaformat = source->mImpl->mSession->getFormat(header->pt);
 
@@ -191,7 +204,7 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
                 frames.push_back(frame);
             }
 
-            source->mImpl->mSink->write(frames);
+            source->mImpl->mSourceStateItem->mSink->write(frames);
         }
     }
 
diff --git a/src/RTPSource.h b/src/RTPSource.h
index 5d0d5e9..16a6f7c 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -30,6 +30,7 @@ public:
     std::string getLocalAddress(const Ice::Current&);
     Ice::Int getLocalPort(const Ice::Current&);
     void setRemoteDetails(std::string address, int port);
+    AsteriskSCF::Media::RTP::V1::RtpStreamSourceStateItemPtr getStateItem();
 
     /**
      * Private implementation data for StreamSourceRTPImpl.

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list