[Opalvoip-svn] SF.net SVN: opalvoip:[29152] opal/branches/v3_12
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2013-02-20 05:46:15
|
Revision: 29152 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=29152&view=rev Author: rjongbloed Date: 2013-02-20 05:46:05 +0000 (Wed, 20 Feb 2013) Log Message: ----------- Added flag for mixer node to automatically shut it down if no participants left, handy for ad hoc conferences. Modified Paths: -------------- opal/branches/v3_12/include/ep/opalmixer.h opal/branches/v3_12/src/ep/opalmixer.cxx Modified: opal/branches/v3_12/include/ep/opalmixer.h =================================================================== --- opal/branches/v3_12/include/ep/opalmixer.h 2013-02-20 03:02:02 UTC (rev 29151) +++ opal/branches/v3_12/include/ep/opalmixer.h 2013-02-20 05:46:05 UTC (rev 29152) @@ -383,6 +383,7 @@ { OpalMixerNodeInfo(const char * name = NULL) : m_name(name) + , m_closeOnEmpty(false) , m_listenOnly(false) , m_sampleRate(OpalMediaFormat::AudioClockRate) #if OPAL_VIDEO @@ -400,6 +401,7 @@ virtual OpalMixerNodeInfo * Clone() const { return new OpalMixerNodeInfo(*this); } PString m_name; ///< Name for mixer node. + bool m_closeOnEmpty; ///< Mixer node is removed when last participant exits bool m_listenOnly; ///< Mixer only transmits data to "listeners" unsigned m_sampleRate; ///< Audio sample rate, usually 8000 #if OPAL_VIDEO @@ -1188,6 +1190,7 @@ PStringSet m_names; OpalMixerNodeInfo * m_info; PTime m_creationTime; + PAtomicBoolean m_shuttingDown; PSafeList<OpalConnection> m_connections; PString m_ownerConnection; Modified: opal/branches/v3_12/src/ep/opalmixer.cxx =================================================================== --- opal/branches/v3_12/src/ep/opalmixer.cxx 2013-02-20 03:02:02 UTC (rev 29151) +++ opal/branches/v3_12/src/ep/opalmixer.cxx 2013-02-20 05:46:05 UTC (rev 29152) @@ -1210,6 +1210,9 @@ void OpalMixerNode::ShutDown() { + if (m_shuttingDown.TestAndSet(true)) + return; + PTRACE(4, "MixerNode\tShutting down " << *this); m_manager.OnNodeStatusChanged(*this, OpalConferenceState::Destroyed); @@ -1226,6 +1229,8 @@ #endif m_manager.RemoveNodeNames(GetNames()); m_names.RemoveAll(); + + m_manager.RemoveNode(*this); } @@ -1291,10 +1296,12 @@ m_manager.OnNodeStatusChanged(*this, OpalConferenceState::UserRemoved); - if (!m_ownerConnection.IsEmpty() && - (m_ownerConnection == connection->GetToken() || - m_ownerConnection == connection->GetLocalPartyURL() || - m_ownerConnection == connection->GetRemotePartyURL())) + if ((m_info->m_closeOnEmpty && m_connections.IsEmpty()) + || + ( !m_ownerConnection.IsEmpty() && + (m_ownerConnection == connection->GetToken() || + m_ownerConnection == connection->GetLocalPartyURL() || + m_ownerConnection == connection->GetRemotePartyURL()))) ShutDown(); } @@ -1845,11 +1852,11 @@ void OpalMixerNodeManager::ShutDown() { PTRACE(4, "Mixer\tDestroying " << m_nodesByUID.GetSize() << '/' << m_nodesByName.GetSize() << " nodes"); - while (!m_nodesByUID.IsEmpty()) { - PSafePtr<OpalMixerNode> node = m_nodesByUID.GetAt(0); + + PSafePtr<OpalMixerNode> node; + while ((node = m_nodesByUID.GetAt(0)) != NULL) node->ShutDown(); - m_nodesByUID.RemoveAt(node->GetGUID()); - } + GarbageCollection(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |