[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "transfer" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Oct 13 15:36:57 CDT 2010


branch "transfer" has been updated
       via  491b40156a8320c71cdb3a207e5643738bb8c5ef (commit)
      from  c750446c331c3a1744ec4212ad306f707c796340 (commit)

Summary of changes:
 src/MediaSplicer.cpp |   64 ++++++++++++++++++++++++++++++++++++++++++++++---
 src/MediaSplicer.h   |    1 +
 2 files changed, 61 insertions(+), 4 deletions(-)


- Log -----------------------------------------------------------------
commit 491b40156a8320c71cdb3a207e5643738bb8c5ef
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Oct 13 18:05:50 2010 -0230

    Resolving an issue that would result in a two party bridge potentially breaking when one session was replaced.

diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index 842878d..c4d12f0 100644
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -38,9 +38,11 @@ namespace BridgeService
     {
     public:
 
-        MediaConnectorI(const std::vector<OutgoingPairing>& outgoing, const std::vector<IncomingPairing>& incoming):
+        MediaConnectorI(const std::vector<OutgoingPairing>& outgoing, const std::vector<IncomingPairing>& incoming, 
+          const MediaConnectorPtr& peer):
             mOutgoing(outgoing),
             mIncoming(incoming),
+            mPeer(peer),
             mConnected(true)
         {
             for(std::vector<OutgoingPairing>::iterator i = mOutgoing.begin(); i != mOutgoing.end(); ++i)
@@ -66,6 +68,16 @@ namespace BridgeService
                 mOutgoing.clear();
                 incoming = mIncoming;
                 mIncoming.clear();
+                mConnected = false;
+            }
+
+            if(outgoing.size() == 0)
+            {
+                lg(Debug) << __FUNCTION__ << ": no outgoing pairings found for this connector!";
+            }
+            if(incoming.size() == 0)
+            {
+                lg(Debug) << __FUNCTION__ << ": no incoming pairings found for this connector!";
             }
 
             //
@@ -109,6 +121,7 @@ namespace BridgeService
                 {
                 }
             }
+            mPeer->clearConnections();
         }
 
         bool isConnected()
@@ -117,13 +130,31 @@ namespace BridgeService
             return mConnected;
         }
 
+        void clearConnections()
+        {
+            IceUtil::Mutex::Lock lock(mMutex);
+            mOutgoing.clear();
+            mIncoming.clear();
+        }
+
+        void update(const MediaConnectorPtr& peer, const std::vector<OutgoingPairing>& outgoing, const std::vector<IncomingPairing>& incoming)
+        {
+            IceUtil::Mutex::Lock lock(mMutex);
+            mPeer = peer;
+            mOutgoing = outgoing;
+            mIncoming = incoming;
+        }
+
     private:
         IceUtil::Mutex mMutex;
         std::vector<OutgoingPairing> mOutgoing;
         std::vector<IncomingPairing> mIncoming;
+        MediaConnectorPtr mPeer;
         bool mConnected;
     };
 
+    typedef IceUtil::Handle<MediaConnectorI> MediaConnectorIPtr;
+
     //
     // TODO: This needs to register the streams with an active threaded mixing element.
     // 
@@ -147,19 +178,21 @@ namespace BridgeService
             //
             // Loop through looking for an identical media session, also reaping disconnected connectors as we go.
             //
-            for(MediaSessions::iterator i = mSessions.begin(); i != mSessions.end(); ++i)
+            MediaSessions::iterator i = mSessions.begin();
+            while(i != mSessions.end())
             {
                 if(!i->connector->isConnected())
                 {
                     lg(Debug) << __FUNCTION__ << ": reaping a connector";
                     MediaSessions::iterator t = i;
-                    mSessions.erase(t);
+                    i = mSessions.erase(t);
                     continue;
                 }
                 if(i->mediaSession == media)
                 {
                     result = i->connector;
                 }
+                ++i;
             }
             if(result)
             {
@@ -168,6 +201,18 @@ namespace BridgeService
             }
 
             //
+            // PRE-ALPHA-ONLY code. When it's a two party bridge and the sessions are added or removed separately,
+            // one of them is going to have an empty connector.
+            //
+             
+            MediaConnectorPtr existing;
+            if(mSessions.size() == 1)
+            {
+                existing = mSessions.back().connector;
+                existing->clearConnections();
+            }
+
+            //
             // Idiom-wise, it is best to defer calling getSources() until after the sinks have all been
             // processed. However, we do not want to do the sink linkup if the getSources fails so we
             // do both calls up here.
@@ -178,9 +223,20 @@ namespace BridgeService
             std::vector<OutgoingPairing> outgoingPairings(findCompatiblePairings(sinks));
             std::vector<IncomingPairing> incomingPairings(findCompatiblePairings(sources));
 
-            result = new MediaConnectorI(outgoingPairings, incomingPairings);
+
+            result = new MediaConnectorI(outgoingPairings, incomingPairings, existing);
             lg(Debug) << __FUNCTION__ << ": established connections, returning connector object"; 
             mSessions.push_back(MediaSessionStruct(media, result));
+
+            //
+            // PRE-ALPHA-ONLY code. When it's a two party bridge and the sessions are added or removed separately,
+            // one of them is going to have an empty connector. Now that we are adding the new connector
+            //
+            if(existing)
+            {
+                MediaConnectorIPtr p = MediaConnectorIPtr::dynamicCast(existing);
+                p->update(result, outgoingPairings, incomingPairings);
+            }
             return result;
         }
 
diff --git a/src/MediaSplicer.h b/src/MediaSplicer.h
index e4d1b77..54e0043 100644
--- a/src/MediaSplicer.h
+++ b/src/MediaSplicer.h
@@ -22,6 +22,7 @@ namespace BridgeService
         virtual ~MediaConnector() {}
         virtual void unplug() = 0;
         virtual bool isConnected() = 0;
+        virtual void clearConnections() = 0;
     };
 
     typedef IceUtil::Handle<MediaConnector> MediaConnectorPtr;

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list