[asterisk-scf-commits] asterisk-scf/release/bridging.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri May 20 12:01:48 CDT 2011


branch "master" has been updated
       via  8cd95c68bbaf4a0fe63b1b4d91587ae4aec1aa36 (commit)
      from  ba502f18be3aa445072142f9bbca16efb61c4df0 (commit)

Summary of changes:
 src/MediaSplicer.cpp    |   32 ++++++++++++++++++++++++--------
 src/MediaSplicer.h      |    1 +
 src/SessionListener.cpp |    2 +-
 src/SessionWrapper.cpp  |    5 ++++-
 4 files changed, 30 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 8cd95c68bbaf4a0fe63b1b4d91587ae4aec1aa36
Author: Brent Eagles <beagles at digium.com>
Date:   Fri May 20 14:30:25 2011 -0230

    Fix a bug that would prevent media sessions from being setup properly.
    Also changed the order of tasks for media setup to create and register
    the connectors prior to attempting to make connections. It fits a bit
    better with the asynchronous nature of how everything works.

diff --git a/src/MediaSplicer.cpp b/src/MediaSplicer.cpp
index de7b7c8..deac0b7 100755
--- a/src/MediaSplicer.cpp
+++ b/src/MediaSplicer.cpp
@@ -22,6 +22,7 @@
 #include <vector>
 #include "ServiceUtil.h"
 #include "SessionWrapper.h"
+#include <boost/enable_shared_from_this.hpp>
 
 //
 // TODO:
@@ -45,7 +46,7 @@ namespace BridgeService
 class MediaSplicerI;
 class MediaConnectorI;
 typedef IceUtil::Handle<MediaConnectorI> MediaConnectorIPtr;
-typedef IceUtil::Handle<MediaSplicerI> MediaSplicerIPtr;
+typedef boost::shared_ptr<MediaSplicerI> MediaSplicerIPtr;
 
 //
 // Some types that are used throughout.
@@ -67,6 +68,7 @@ struct MediaConnectorBuilder : public IceUtil::Shared
     AsteriskSCF::Media::V1::StreamSourceSeq sources;
     AsteriskSCF::Media::V1::StreamSinkSeq sinks;
     MediaConnectorIPtr peer;
+    MediaConnectorIPtr connector;
     OutgoingPairings outgoingPairings;
     IncomingPairings incomingPairings;
 };
@@ -432,7 +434,7 @@ QueuedTasks createMediaConnectTasks(const SessionWrapperPtr& session,
 //
 // TODO: This needs to register the streams with an active threaded mixing element.
 //
-class MediaSplicerI : public IceUtil::Shared
+class MediaSplicerI : public boost::enable_shared_from_this<MediaSplicerI>
 {
 public:
     MediaSplicerI(const Ice::CommunicatorPtr& communicator, const string& bridgeId, const ReplicatorSmartPrx& replicator, const Logger& logger) :
@@ -496,7 +498,8 @@ public:
         // We do not bother tracking the executor for now. A tidy shutdown would probably want to clean this up.
         // An alternative is to pass back the queued tasks to the caller and let them start and stop the process.
         //
-        ExecutorPtr taskExecutor(new Executor(createMediaConnectTasks(session, sessionPrx, existing, this), mLogger));
+        ExecutorPtr taskExecutor(new Executor(createMediaConnectTasks(session, sessionPrx, existing, 
+            shared_from_this()), mLogger));
         taskExecutor->start();
     }
 
@@ -671,8 +674,6 @@ private:
     }
 };
 
-typedef IceUtil::Handle<MediaSplicerI> MediaSplicerIPtr;
-
 class GetMediaSession : public QueuedTask
 {
 public:
@@ -879,6 +880,16 @@ protected:
     
     bool executeImpl()
     {
+        if (mMaterials->incomingPairings.empty() && mMaterials->outgoingPairings.empty())
+        {
+            //
+            // This *will* happen for the first session added to the bridge. We *must* allow the
+            // next task to run. If there are pairings, the AMI response callbacks wil take care of 
+            // kicking off the next task.
+            //
+            return true;
+        }
+
         //
         // If there are lots of pairings, this could result in a "flurry" of AMI requests. I'm not sure that it is
         // anything to worry about though. Ice will queue the requests and send them according to the "send" threads
@@ -900,6 +911,7 @@ protected:
             i->second->begin_setSource(i->first,  AsteriskSCF::Media::V1::newCallback_StreamSink_setSource(h, &IncomingHelper::setSourceCB, &IncomingHelper::failed));
             ++index;
         }
+
         return false;
     }
 
@@ -917,6 +929,10 @@ protected:
         }
         if (done)
         {
+            if (mMaterials->connector)
+            {
+                mMaterials->connector->update(mMaterials->peer, mMaterials->outgoingPairings, mMaterials->incomingPairings);
+            }
             mListener->succeeded();
         }
     }
@@ -990,8 +1006,8 @@ public:
 
     bool executeImpl()
     {
-        MediaConnectorPtr connector(mSplicer->createConnector(mSession, mMaterials));
-        mSession->setConnector(connector);
+        mMaterials->connector =  MediaConnectorIPtr::dynamicCast(mSplicer->createConnector(mSession, mMaterials));
+        mSession->setConnector(mMaterials->connector);
         return true;
     }
     
@@ -1012,9 +1028,9 @@ QueuedTasks createMediaConnectTasks(const SessionWrapperPtr& session,
     tasks.push_back(new GetMediaSession(session, materials));
     tasks.push_back(new GetSinks(materials));
     tasks.push_back(new GetSources(materials));
+    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 CreateAndRegisterConnector(session, splicer, materials));
     return tasks;
 }
 
diff --git a/src/MediaSplicer.h b/src/MediaSplicer.h
index 6440d34..835374d 100644
--- a/src/MediaSplicer.h
+++ b/src/MediaSplicer.h
@@ -22,6 +22,7 @@
 #include <memory>
 #include "BridgeServiceConfig.h"
 #include "BridgeReplicatorIf.h"
+#include <boost/shared_ptr.hpp>
 
 namespace AsteriskSCF
 {
diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 86a2fca..585f9f4 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -139,7 +139,7 @@ public:
                         mBridgePrx->shutdown();
                     }
                 }
-                catch (const Ice::Exception& ex)
+                catch (const Ice::Exception&)
                 {
                     mLogger(Error) << "Unexpected exception when initiating auto shutdown";
                 }
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index d514e3b..c447486 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -420,7 +420,10 @@ void SessionWrapper::setupMedia()
 {
     mLogger(Debug) << FUNLOG << " for " << mId;
     boost::unique_lock<boost::shared_mutex> lock(mLock);
-    mSplicer->connect(this, mSession->session);
+    if (!mConnector)
+    {
+        mSplicer->connect(this, mSession->session);
+    }
 }
 
 void SessionWrapper::setConnector(const MediaConnectorPtr& connector)

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


-- 
asterisk-scf/release/bridging.git



More information about the asterisk-scf-commits mailing list