[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "directmedia" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Jul 24 13:03:26 CDT 2011


branch "directmedia" has been created
        at  36db8f6907892ff78b3e7a6a1d1b777001e40371 (commit)

- Log -----------------------------------------------------------------
commit 36db8f6907892ff78b3e7a6a1d1b777001e40371
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jul 24 15:05:03 2011 -0300

    Add bridging part for direct media connection support. Now to fix some bugs in the SIP side!

diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index f3e16a7..d7d6dc8 100755
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -74,6 +74,7 @@ struct MediaConnectorBuilder : public IceUtil::Shared
     OutgoingPairings outgoingPairings;
     IncomingPairings incomingPairings;
     std::map<std::string, std::string> connections;
+    DirectMediaConnectionDict directConnections;
 };
 typedef IceUtil::Handle<MediaConnectorBuilder> MediaConnectorBuilderPtr;
 
@@ -495,7 +496,8 @@ public:
     void findCompatiblePairings(const StreamInformationDict& streams, vector<OutgoingPairing>& outgoing,
                                 vector<IncomingPairing>& incoming,
                                 MediaConnectorIPtr connector,
-                                std::map<std::string, std::string>& connections)
+                                std::map<std::string, std::string>& connections,
+                                DirectMediaConnectionDict& directConnections)
     {
         // If no streams are present we can not establish any pairings
         if (streams.empty())
@@ -549,6 +551,9 @@ public:
 		    StreamSinkSeq sinks = stream->second->sinks;
 		    StreamSourceSeq sources = stream->second->sources;
 
+                    // Attempt to establish a direct connection later
+                    directConnections.insert(make_pair(stream->first, theirStream->second->sinks.front()));
+
 		    while (!sinks.empty() && !theirStream->second->sources.empty())
 		    {
                         outgoing.push_back(OutgoingPairing(sinks.back(), theirStream->second->sources.back()));
@@ -682,7 +687,7 @@ protected:
     bool executeImpl()
     {
 	mSplicer->findCompatiblePairings(mMaterials->streams, mMaterials->outgoingPairings, mMaterials->incomingPairings,
-                                         mMaterials->connector, mMaterials->connections);
+                                         mMaterials->connector, mMaterials->connections, mMaterials->directConnections);
         return true;
     }
 
@@ -919,6 +924,67 @@ private:
     MediaConnectorBuilderPtr mMaterials;
 };
 
+class MakeDirectConnections : public QueuedTask
+{
+public:
+    MakeDirectConnections(const MediaConnectorBuilderPtr& materials) :
+        QueuedTask("MakeDirectConnections"),
+        mMaterials(materials)
+        {
+        }
+
+protected:
+    bool executeImpl()
+    {
+        mDirectConnection = DirectMediaConnectionPrx::checkedCast(mMaterials->sessionPrx, directMediaConnectionFacet);
+
+        if (!mDirectConnection)
+        {
+            return true;
+        }
+
+        mDirectConnection->begin_checkDirectConnections(mMaterials->directConnections, newCallback_DirectMediaConnection_checkDirectConnections(
+                                                            this, &MakeDirectConnections::accepted, &MakeDirectConnections::failed));
+
+        return false;
+    }
+
+    void accepted(const Ice::StringSeq& streams)
+    {
+        if (streams.empty())
+        {
+            mListener->succeeded();
+            return;
+        }
+
+        DirectMediaConnectionDict directConnections;
+
+        for (Ice::StringSeq::const_iterator stream = streams.begin();
+             stream != streams.end();
+             ++stream)
+        {
+            directConnections.insert(make_pair(*stream, mMaterials->directConnections.find(*stream)->second));
+        }
+
+        mDirectConnection->begin_connectStreams(directConnections, newCallback_DirectMediaConnection_connectStreams(this,
+                                                                                                                    &MakeDirectConnections::done,
+                                                                                                                    &MakeDirectConnections::failed));
+    }
+
+    void done()
+    {
+        mListener->succeeded();
+    }
+
+    void failed(const Ice::Exception&)
+    {
+        mListener->failed();
+    }
+private:
+    MediaConnectorBuilderPtr mMaterials;
+    DirectMediaConnectionPrx mDirectConnection;
+};
+
 QueuedTasks createMediaConnectTasks(const SessionWrapperPtr& session, 
     const AsteriskSCF::SessionCommunications::V1::SessionPrx& sessionPrx, 
     const MediaConnectorIPtr& peer, const MediaSplicerIPtr& splicer)
@@ -931,6 +997,7 @@ QueuedTasks createMediaConnectTasks(const SessionWrapperPtr& session,
     tasks.push_back(new CreateAndRegisterConnector(session, splicer, materials));
     tasks.push_back(new GetCompatiblePairings(splicer, materials));
     tasks.push_back(new MakeConnections(materials));
+    tasks.push_back(new MakeDirectConnections(materials));
     return tasks;
 }
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list