sofaswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
July 2008
- 1 participants
- 15 discussions
28 Jul '08
Author: derek
Date: Sun Jul 27 22:22:05 2008
New Revision: 438
Modified:
sofaswitch/trunk/am/main.cxx
sofaswitch/trunk/am/manager.cxx
sofaswitch/trunk/am/manager.h
sofaswitch/trunk/am/supervisor.cxx
sofaswitch/trunk/mcu/main.cxx
sofaswitch/trunk/mcu/manager.cxx
sofaswitch/trunk/mcu/manager.h
sofaswitch/trunk/voip/main.cxx
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
Log:
Correctly cope with the times when the supervisor could not connect to
the server. Should be more robust now on startup..
Modified: sofaswitch/trunk/am/main.cxx
==============================================================================
--- sofaswitch/trunk/am/main.cxx (original)
+++ sofaswitch/trunk/am/main.cxx Sun Jul 27 22:22:05 2008
@@ -29,6 +29,7 @@
#include "manager.h"
#include "main.h"
#include <sofa/messages.h>
+#include "supervisor.h"
#include "version.h"
@@ -128,20 +129,24 @@
}
LaunchNewId lid(ourId, ourPassword);
- opal = new Manager(lid, ourId, ourPassword);
- opal->StartSupervisor();
- if (opal->WaitUntilSupervisorOk())
- opal->Main();
- else
- cerr << "The supervisor did not connect to the remote server. Sigh" << endl;
-
- PTRACE(3, "Now end the opal thing");
-
- opal->WaitForSupervisorEnd();
+ Supervisor *s = NULL;;
+ do {
+ if (s != NULL) {
+ s->Terminate();
+ s->WaitForTermination();
+ delete s;
+ }
+ s = new Supervisor(lid);
+ s->Resume();
+ s->WaitUntilInitialised();
+ }
+ while (s->IsTerminating());
+ opal = new Manager(lid, s, ourId, ourPassword);
+ opal->Main();
delete opal;
-
+ delete s;
PThread::Sleep(1000);
}
Modified: sofaswitch/trunk/am/manager.cxx
==============================================================================
--- sofaswitch/trunk/am/manager.cxx (original)
+++ sofaswitch/trunk/am/manager.cxx Sun Jul 27 22:22:05 2008
@@ -45,9 +45,11 @@
////////////////////////////////////////////////////////////////////////////////
Manager::Manager(LaunchNewId & _lid,
- PString & _ourId, PString & _ourPassword)
+ Supervisor *s,
+ PString & _ourId,
+ PString & _ourPassword)
: lid(_lid),
- supervisor(*(new Supervisor(lid))),
+ supervisor(*s),
ourPassword(_ourPassword),
ourId(_ourId),
runningComms(NULL)
@@ -68,17 +70,11 @@
/* eradicate all current calls */
supervisor.Terminate();
supervisor.WaitForTermination();
- delete & supervisor;
delete runningComms;
runningComms = NULL;
}
-void Manager::StartSupervisor()
-{
- supervisor.Resume();
-}
-
Comms * Manager::ClearCommsId(const PString &memberId)
{
PTRACE(3, "Clear comms Id on " << memberId);
@@ -111,16 +107,6 @@
return NULL;
}
-bool Manager::WaitUntilSupervisorOk()
-{
- return supervisor.WaitUntilInitialised();
-}
-
-void Manager::WaitForSupervisorEnd()
-{
- supervisor.WaitForTermination();
-}
-
void Manager::RequestNewId(const PStringArray & cmds,
const PString & requester)
{
Modified: sofaswitch/trunk/am/manager.h
==============================================================================
--- sofaswitch/trunk/am/manager.h (original)
+++ sofaswitch/trunk/am/manager.h Sun Jul 27 22:22:05 2008
@@ -66,7 +66,10 @@
public:
/**Constructor */
- Manager(LaunchNewId & lid, PString & ourId, PString & ourPassword);
+ Manager(LaunchNewId & lid,
+ Supervisor *_supervisor,
+ PString & ourId,
+ PString & ourPassword);
/**destructor */
~Manager();
@@ -120,16 +123,6 @@
RequestNewId commands */
Comms *RemoveFromPreCallQueue(const PString & preferredId);
- /**Get the supervisor to start processing messages */
- void StartSupervisor();
-
- /**Wait (up to 1 second) to see if the supervisor is installed and
- connected OK. */
- bool WaitUntilSupervisorOk();
-
- /**Wait until the supervisor has finished */
- void WaitForSupervisorEnd();
-
/**Cause the comms instance in activeCalls to be moved to the dead
comms list. Give no error if the specified comms instance could
not be found */
Modified: sofaswitch/trunk/am/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/am/supervisor.cxx (original)
+++ sofaswitch/trunk/am/supervisor.cxx Sun Jul 27 22:22:05 2008
@@ -67,10 +67,7 @@
void Supervisor::OnTermination()
{
- Manager *mgr = AmProcess::Current().GetManager();
- mgr->RemoveAllCalls();
-
- PTRACE(3, "Destructor Supervisor thread has ended");
+ PTRACE(3, "Supervisor thread has ended");
}
void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender)
Modified: sofaswitch/trunk/mcu/main.cxx
==============================================================================
--- sofaswitch/trunk/mcu/main.cxx (original)
+++ sofaswitch/trunk/mcu/main.cxx Sun Jul 27 22:22:05 2008
@@ -32,6 +32,7 @@
#include "manager.h"
#include "main.h"
#include "sofa/messages.h"
+#include "supervisor.h"
#include "version.h"
@@ -134,19 +135,28 @@
PTRACE(3, "Select a default password of " << ourPassword);
}
- LaunchNewId lid(ourId, ourPassword);
- opal = new Manager(lid, ourId, ourPassword);
- opal->StartSupervisor();
-
- if (opal->WaitUntilSupervisorOk())
- opal->Main();
- else
- cerr << "The supervisor did not connect to the remote server. Sigh" << endl;
+ LaunchNewId lid(ourId, ourPassword);
+ Supervisor *s = NULL;
+ do {
+ if (s != NULL) {
+ s->Terminate();
+ s->WaitForTermination();
+ delete s;
+ }
+ s = new Supervisor(lid);
+ s->Resume();
+ s->WaitUntilInitialised();
+ }
+ while (s->IsTerminating());
+
+ opal = new Manager(lid, s, ourId, ourPassword);
- PTRACE(3, "Now end the opal thing");
- opal->WaitForSupervisorEnd();
+ opal->Main();
delete opal;
+
+ delete s;
+
PThread::Sleep(1000);
}
Modified: sofaswitch/trunk/mcu/manager.cxx
==============================================================================
--- sofaswitch/trunk/mcu/manager.cxx (original)
+++ sofaswitch/trunk/mcu/manager.cxx Sun Jul 27 22:22:05 2008
@@ -56,9 +56,10 @@
/////////////////////////////////////////////////////////////////////////////
Manager::Manager(LaunchNewId & _lid,
- PString & _ourId, PString & _ourPassword)
+ Supervisor * _supervisor,
+ PString & _ourId, PString & _ourPassword)
: lid(_lid),
- supervisor(*(new Supervisor(lid))),
+ supervisor(* _supervisor),
ourPassword(_ourPassword),
ourId(_ourId),
runningComms(NULL)
@@ -88,8 +89,6 @@
delete runningComms;
runningComms = NULL;
- delete & supervisor;
-
garbageExit.Signal();
garbageFinished.Wait();
@@ -154,21 +153,6 @@
PTRACE(3, "Manager\tFinish CollectGarbage");
}
-bool Manager::WaitUntilSupervisorOk()
-{
- return supervisor.WaitUntilInitialised();
-}
-
-void Manager::WaitForSupervisorEnd()
-{
- supervisor.WaitForTermination();
-}
-
-void Manager::StartSupervisor()
-{
- supervisor.Resume();
-}
-
void Manager::RemoveMemberId(const PString & memberId)
{
PTRACE(3, "Remove MemberID \"" << memberId << "\" START");
Modified: sofaswitch/trunk/mcu/manager.h
==============================================================================
--- sofaswitch/trunk/mcu/manager.h (original)
+++ sofaswitch/trunk/mcu/manager.h Sun Jul 27 22:22:05 2008
@@ -62,7 +62,10 @@
public:
/**Constructor */
- Manager(LaunchNewId & lid, PString & ourId, PString & ourPassword);
+ Manager(LaunchNewId & lid,
+ Supervisor *s,
+ PString & ourId,
+ PString & ourPassword);
/**destructor */
~Manager();
@@ -124,16 +127,6 @@
RequestNewId commands */
Comms *RemoveFromPreCallQueue(const PString & preferredId);
- /**Wait (up to 1 second) to see if the supervisor is installed and
- connected OK. */
- bool WaitUntilSupervisorOk();
-
- /**Get the supervisor to start processing messages */
- void StartSupervisor();
-
- /**Wait until the supervisor has finished */
- void WaitForSupervisorEnd();
-
/**Get the status on all conferences, or just one conference */
PString ProcessStatusQuery(const PStringArray & cmds);
Modified: sofaswitch/trunk/voip/main.cxx
==============================================================================
--- sofaswitch/trunk/voip/main.cxx (original)
+++ sofaswitch/trunk/voip/main.cxx Sun Jul 27 22:22:05 2008
@@ -52,6 +52,7 @@
#include "main.h"
#include <sofa/messages.h>
#include "counts.h"
+#include "supervisor.h"
#include "version.h"
@@ -278,7 +279,19 @@
}
LaunchNewId lid(ourId, ourPassword);
- opal = new MyManager(lid, ourId, ourPassword);
+ Supervisor *s = NULL;;
+ do {
+ if (s != NULL) {
+ s->Terminate();
+ s->WaitForTermination();
+ delete s;
+ }
+ s = new Supervisor(lid);
+ s->Resume();
+ s->WaitUntilInitialised();
+ }
+ while (s->IsTerminating());
+ opal = new MyManager(lid, s,ourId, ourPassword);
if (opal->Initialise(args)) {
opal->Main(args);
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 27 22:22:05 2008
@@ -82,10 +82,11 @@
///////////////////////////////////////////////////////////////
MyManager::MyManager(LaunchNewId & _lid,
+ Supervisor * _supervisor,
PString & _ourId, PString & _ourPassword)
: lid(_lid),
-supervisor(*(new Supervisor(lid))),
-runningComms(*new CommsProvider(lid, *this))
+ supervisor(*_supervisor),
+ runningComms(*new CommsProvider(lid, *this))
{
allocationNumber = 0;
IncMyManager();
@@ -126,12 +127,6 @@
bool MyManager::Initialise(PArgList & args)
{
- if (!supervisor.WaitUntilInitialised()) {
- cerr << "The supervisor could not connect to the remote server. Sorry." << endl;
- return false;
- }
-
-
if (args.HasOption('j')) {
unsigned minJitter;
unsigned maxJitter;
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Sun Jul 27 22:22:05 2008
@@ -66,7 +66,9 @@
public:
/**Constructor */
- MyManager(LaunchNewId & lid, PString & ourId, PString & ourPassword);
+ MyManager(LaunchNewId & lid,
+ Supervisor * _supervisor,
+ PString & ourId, PString & ourPassword);
/**destructor */
~MyManager();
1
0
27 Jul '08
Author: derek
Date: Sun Jul 27 19:56:10 2008
New Revision: 437
Modified:
sofaswitch/trunk/callflow/src/dnd.cpp
sofaswitch/trunk/callflow/src/requestnode.cpp
sofaswitch/trunk/callflow/src/requestnode.h
sofaswitch/trunk/callflow/src/shapelist.cpp
Log:
check that the user has specified a python variable to
hold the output of the requestnewid operation. mark this
as a compile error if name not specified. Ensure this
compile error is correctly cleared on doing the next compile.
Modified: sofaswitch/trunk/callflow/src/dnd.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/dnd.cpp (original)
+++ sofaswitch/trunk/callflow/src/dnd.cpp Sun Jul 27 19:56:10 2008
@@ -407,7 +407,6 @@
bool DndShape::TestInternalVariables()
{
- ClearCompileError();
return true;
}
Modified: sofaswitch/trunk/callflow/src/requestnode.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/requestnode.cpp (original)
+++ sofaswitch/trunk/callflow/src/requestnode.cpp Sun Jul 27 19:56:10 2008
@@ -88,6 +88,20 @@
DndShape::Draw(dc);
}
+
+bool DndShapeRequestNode::TestInternalVariables()
+{
+ if (displayData[4].data.IsEmpty()) {
+ wxString error;
+ error = wxT("You must supply a valid Python expression as \n");
+ error = error + wxT("the name of the requested SofaSwitch worker");
+ SetCompileError(error);
+ return false;
+ }
+ return true;
+}
+
+
bool DndShapeRequestNode::WriteSystemCode(wxTextFile & file)
{
file.AddLine(wxT(" def Request_Node(self, aTuple): "));
Modified: sofaswitch/trunk/callflow/src/requestnode.h
==============================================================================
--- sofaswitch/trunk/callflow/src/requestnode.h (original)
+++ sofaswitch/trunk/callflow/src/requestnode.h Sun Jul 27 19:56:10 2008
@@ -24,6 +24,12 @@
/**Draw this particular shape to the screen..*/
virtual void Draw(wxDC& dc);
+ /**Make cerrtain that the intenal variables have been set
+ correctly, so this shape will compile into good
+ code. Essentially, test that there is a python variable
+ specified to hold the derived name.*/
+ virtual bool TestInternalVariables();
+
/** Used to report the name of this particular class. */
static wxString GetKindName() { return wxT("Request Node"); }
Modified: sofaswitch/trunk/callflow/src/shapelist.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/shapelist.cpp (original)
+++ sofaswitch/trunk/callflow/src/shapelist.cpp Sun Jul 27 19:56:10 2008
@@ -273,7 +273,8 @@
while (it != end()) {
DndShape *thisShape = it->second;
if (thisShape != NULL) {
- variablesOk = thisShape->TestInternalVariables();
+ thisShape->ClearCompileError();
+ variablesOk = thisShape->TestInternalVariables();
}
it++;
}
1
0
27 Jul '08
Author: derek
Date: Sun Jul 27 19:26:14 2008
New Revision: 436
Modified:
sofaswitch/trunk/callflow/src/requestnode.cpp
Log:
Tidy up the errorchecking - ensure that the python code
copes with faulty input better.
Modified: sofaswitch/trunk/callflow/src/requestnode.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/requestnode.cpp (original)
+++ sofaswitch/trunk/callflow/src/requestnode.cpp Sun Jul 27 19:26:14 2008
@@ -96,13 +96,25 @@
file.AddLine(wxT(" if y == 0: "));
file.AddLine(wxT(" define=self.data[a][\"Event Source\"] "));
file.AddLine(wxT(" define = define + \" = None\" "));
- file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"Did you specifiy a python variable for the event source for\", a "));
+ file.AddLine(wxT(" exit "));
file.AddLine(wxT(" define=self.data[a][\"Event Name\"] "));
file.AddLine(wxT(" define = define + \" = None\" "));
- file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"Did you specifiy a python variable for the event name for\", a "));
+ file.AddLine(wxT(" exit "));
file.AddLine(wxT(" define=self.data[a][\"Event Data\"] "));
file.AddLine(wxT(" define = define + \" = None\" "));
- file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" exec(define); "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"Did you specifiy a python variable for the event data for\", a "));
+ file.AddLine(wxT(" exit "));
file.AddLine(wxT(" self.pendingEvents[eName] = (a, eName, \"\") "));
file.AddLine(wxT(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"));
file.AddLine(wxT(" rNode = self.data[a][\"Request node from\"] "));
1
0
27 Jul '08
Author: derek
Date: Sun Jul 27 01:22:16 2008
New Revision: 435
Modified:
sofaswitch/trunk/callflow/src/requestnode.cpp
sofaswitch/trunk/callflow/src/shapelist.cpp
Log:
requestnewid command is changed, to now include a unique identifying string.
this means one RequestNewId node on the panel will not interfere with another.
Alternatively, multiple uses of a RequestNewid node on the panel will not
interfere with another.
Modified: sofaswitch/trunk/callflow/src/requestnode.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/requestnode.cpp (original)
+++ sofaswitch/trunk/callflow/src/requestnode.cpp Sun Jul 27 01:22:16 2008
@@ -111,7 +111,8 @@
file.AddLine(wxT(" except: "));
file.AddLine(wxT(" print \"Could not process \", rNode, \" as a Python string\" "));
file.AddLine(wxT(" return self.data[a][\"Output\"] "));
- file.AddLine(wxT(" rhost = rhost + \":REQUESTNEWID \" "));
+ file.AddLine(wxT(" rnewid = \"REQUESTNEWID\" + str(random.random()) "));
+ file.AddLine(wxT(" rhost = rhost + \":\" + rnewid + \" \" "));
file.AddLine(wxT(" additional = self.data[a][\"Additional info\"] "));
file.AddLine(wxT(" if len(additional) > 0: "));
file.AddLine(wxT(" try: "));
@@ -122,7 +123,7 @@
file.AddLine(wxT(" rhost += \"\\0\" "));
file.AddLine(wxT(" self.transport.write(rhost) "));
file.AddLine(wxT(" self.currentHandlers[eName] = a "));
- file.AddLine(wxT(" rEvent = eval(rNode) + \"REQUESTNEWID\" "));
+ file.AddLine(wxT(" rEvent = eval(rNode) + rnewid "));
file.AddLine(wxT(" self.currentHandlers[rEvent] = a "));
file.AddLine(wxT(" return self.data[a][\"Output\"] "));
file.AddLine(wxT(" else: "));
Modified: sofaswitch/trunk/callflow/src/shapelist.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/shapelist.cpp (original)
+++ sofaswitch/trunk/callflow/src/shapelist.cpp Sun Jul 27 01:22:16 2008
@@ -334,6 +334,7 @@
file.AddLine(wxT("#!/usr/bin/python "));
file.AddLine(wxT(" "));
file.AddLine(wxT("import sys "));
+ file.AddLine(wxT("import random "));
file.AddLine(wxT("import os "));
file.AddLine(wxT("import time "));
file.AddLine(wxT("import socket "));
1
0
Author: derek
Date: Sun Jul 27 01:11:44 2008
New Revision: 434
Modified:
sofaswitch/trunk/mcu/member.cxx
sofaswitch/trunk/mcu/member.h
Log:
use a read write lock on the internal audio buffer,
so it is more efficient in handling audio. This will
allow concurrent reads of the member's audio buffer.
Modified: sofaswitch/trunk/mcu/member.cxx
==============================================================================
--- sofaswitch/trunk/mcu/member.cxx (original)
+++ sofaswitch/trunk/mcu/member.cxx Sun Jul 27 01:11:44 2008
@@ -44,18 +44,6 @@
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
-// size of a PCM data packet, in samples
-#define PCM_PACKET_LEN 240
-
-// size of a PCM data buffer, in bytes
-#define PCM_BUFFER_LEN (PCM_PACKET_LEN * 2)
-
-// number of PCM buffers to keep
-#define PCM_BUFFER_COUNT 2
-
-#define PCM_BUFFER_SIZE (10 * PCM_BUFFER_LEN * PCM_BUFFER_COUNT)
-
-
///////////////////////////////////////////////////////////////
void MemberDict::DeleteObject(PObject * object) const
@@ -81,7 +69,6 @@
keepGoing = true;
bufferSize = PCM_BUFFER_SIZE;
- buffer = new BYTE[bufferSize];
memset(buffer, 0, bufferSize);
currentWriteIndex = 0;
@@ -92,14 +79,6 @@
{
PTRACE(2, "Member\t" << *this << " destroyed dead and gone");
- {
- PWaitAndSignal m(audioBufferMutex);
- if (buffer != NULL) {
- delete [] buffer;
- buffer = NULL;
- }
- }
-
DecCountMembers();
}
@@ -172,25 +151,20 @@
if (amount == 0)
return;
- PWaitAndSignal mutex(audioBufferMutex);
-
- if (buffer == NULL) {
- PTRACE(3, "Audio buffer is null - abort ReadAndMixAudio");
- return;
- }
-
+ audioBufferMutex.StartWrite();
if ((currentWriteIndex + amount) > bufferSize) {
- PINDEX bytesLeftOver;
- bytesLeftOver = (currentWriteIndex + amount) - bufferSize;
-
- memcpy(buffer + currentWriteIndex, dataPtr, amount - bytesLeftOver);
- memcpy(buffer, dataPtr + amount - bytesLeftOver, bytesLeftOver);
-
- currentWriteIndex = bytesLeftOver;
+ PINDEX bytesLeftOver;
+ bytesLeftOver = (currentWriteIndex + amount) - bufferSize;
+
+ memcpy(buffer + currentWriteIndex, dataPtr, amount - bytesLeftOver);
+ memcpy(buffer, dataPtr + amount - bytesLeftOver, bytesLeftOver);
+
+ currentWriteIndex = bytesLeftOver;
} else {
- memcpy(buffer + currentWriteIndex, dataPtr, amount);
- currentWriteIndex += amount;
+ memcpy(buffer + currentWriteIndex, dataPtr, amount);
+ currentWriteIndex += amount;
}
+ audioBufferMutex.EndWrite();
}
void Member::ReadAudio(BYTE *dataPtr, PINDEX readSize)
@@ -208,13 +182,7 @@
return keepGoing;
}
- PWaitAndSignal mutex(audioBufferMutex);
-
- if (buffer == NULL) {
- PTRACE(3, "Audio buffer is null - abort ReadAndMixAudio");
- return keepGoing;
- }
-
+ audioBufferMutex.StartRead();
PINDEX availableBytes;
if (currentReadIndex > currentWriteIndex)
availableBytes = (bufferSize + currentWriteIndex) - currentReadIndex;
@@ -239,6 +207,7 @@
Mix(data, buffer + currentReadIndex, amount);
currentReadIndex += amount;
}
+ audioBufferMutex.EndRead();
return keepGoing;
}
Modified: sofaswitch/trunk/mcu/member.h
==============================================================================
--- sofaswitch/trunk/mcu/member.h (original)
+++ sofaswitch/trunk/mcu/member.h Sun Jul 27 01:11:44 2008
@@ -34,7 +34,17 @@
#ifdef P_USE_PRAGMA
#pragma interface
#endif
+// size of a PCM data packet, in samples
+#define PCM_PACKET_LEN 240
+// size of a PCM data buffer, in bytes
+#define PCM_BUFFER_LEN (PCM_PACKET_LEN * 2)
+
+// number of PCM buffers to keep
+#define PCM_BUFFER_COUNT 2
+
+#define PCM_BUFFER_SIZE (10 * PCM_BUFFER_LEN * PCM_BUFFER_COUNT)
+
#include <ptlib/safecoll.h>
class ConferenceRoom;
@@ -186,7 +196,7 @@
This buffer is circular, in that once data has been written to
the end, data will then be written to the start */
- BYTE * buffer;
+ BYTE buffer[PCM_BUFFER_SIZE];
/** The position that we next put data to */
PINDEX currentWriteIndex;
@@ -194,8 +204,10 @@
/** Total number of bytes in buffer. Never gets changed.*/
PINDEX bufferSize;
- /**Lock on the audio buffer & assocated variables */
- PMutex audioBufferMutex;
+ /**Lock on the audio buffer & assocated variables. This is a
+ read/write lock, so we can have concurent reads of the audio in
+ this buffer */
+ PReadWriteMutex audioBufferMutex;
//@}
/**The time at which this structure was created, which is the time this call
1
0
[Sofaswitch-svn] [commit] r433 - in sofaswitch/trunk: am mcu sofa/include/sofa sofa/src voip
by SofaSWITCH SVN 27 Jul '08
by SofaSWITCH SVN 27 Jul '08
27 Jul '08
Author: derek
Date: Sun Jul 27 00:47:16 2008
New Revision: 433
Modified:
sofaswitch/trunk/am/comms.cxx
sofaswitch/trunk/am/comms.h
sofaswitch/trunk/am/manager.cxx
sofaswitch/trunk/am/manager.h
sofaswitch/trunk/am/supervisor.cxx
sofaswitch/trunk/am/supervisor.h
sofaswitch/trunk/mcu/comms.cxx
sofaswitch/trunk/mcu/comms.h
sofaswitch/trunk/mcu/conferenceroom.cxx
sofaswitch/trunk/mcu/conferenceroom.h
sofaswitch/trunk/mcu/manager.cxx
sofaswitch/trunk/mcu/manager.h
sofaswitch/trunk/mcu/supervisor.cxx
sofaswitch/trunk/mcu/supervisor.h
sofaswitch/trunk/sofa/include/sofa/messages.h
sofaswitch/trunk/sofa/src/messages.cxx
sofaswitch/trunk/voip/comms.cxx
sofaswitch/trunk/voip/comms.h
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
sofaswitch/trunk/voip/supervisor.cxx
sofaswitch/trunk/voip/supervisor.h
Log:
Big tidy up. Move all comamnd handling to use Const,
so that the strings are handled as efficiently as possible.
Modified: sofaswitch/trunk/am/comms.cxx
==============================================================================
--- sofaswitch/trunk/am/comms.cxx (original)
+++ sofaswitch/trunk/am/comms.cxx Sun Jul 27 00:47:16 2008
@@ -72,7 +72,7 @@
new CommsConsumer(manager, this);
}
-void Comms::ProcessTransferUdp(PStringArray &cmds, PString & sender)
+void Comms::ProcessTransferUdp(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "Comms::ProcessTransferUdp " << cmds);
@@ -143,7 +143,7 @@
createdAt = PTime();
}
-void Comms::ProcessHangup(PStringArray &cmds, PString & sender)
+void Comms::ProcessHangup(const PStringArray &cmds, const PString & sender)
{
SilentlyEndAll();
}
@@ -158,12 +158,12 @@
}
-void Comms::ProcessCallNode(PStringArray &cmds, PString & sender)
+void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender)
{
// manager.StartCall(cmds[1], sender, GetOurId());
}
-void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "Coms::ProcessStatusQuery");
@@ -205,25 +205,25 @@
return duration;
}
-void Comms::ProcessDuration(PStringArray &cmds, PString & sender)
+void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender)
{
PString duration = GetDurationInfo();
SendThisMessageTo(duration, sender);
}
-void Comms::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
PStringStream message;
message << "Sofa Switch Answering Machine for call " + GetOurId();
SendThisMessageTo(message, sender);
}
-void Comms::ProcessDebug(PStringArray &cmds, PString & sender)
+void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender);
}
-void Comms::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "We answer this call automatically, so thankyou");
}
Modified: sofaswitch/trunk/am/comms.h
==============================================================================
--- sofaswitch/trunk/am/comms.h (original)
+++ sofaswitch/trunk/am/comms.h Sun Jul 27 00:47:16 2008
@@ -110,32 +110,32 @@
transferred, we move ourselves out of the Manager's list of
pending calls. Then we call the ancestor method to actually do
the work of transferring the udp */
- virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender);
+ virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender);
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a Call other Node command, so do it and reply accordingly*/
- virtual void ProcessCallNode(PStringArray &cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly*/
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a command queryig the current call duration ,
so extract information & answer */
- virtual void ProcessDuration(PStringArray &cmds, PString & sender);
+ virtual void ProcessDuration(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us how to answer to the
incoming call, so we act as required and reply accordingly*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**Send this dtmf string to the remote node. Returns true on
success, false on failure. */
Modified: sofaswitch/trunk/am/manager.cxx
==============================================================================
--- sofaswitch/trunk/am/manager.cxx (original)
+++ sofaswitch/trunk/am/manager.cxx Sun Jul 27 00:47:16 2008
@@ -121,15 +121,21 @@
supervisor.WaitForTermination();
}
-void Manager::RequestNewId(const PString & requester)
+void Manager::RequestNewId(const PStringArray & cmds,
+ const PString & requester)
{
Comms *c = runningComms->GetNextComms();
- if (c == NULL)
- return;
+ if (c == NULL) {
+ PStringStream msg;
+ msg << cmds[0] << " failed as could not get the next comms to use";
+ supervisor.SendThisMessageTo(msg, requester);
+ return;
+ }
c->SetRemoteController(requester);
nodesMakingCalls.AddNewMessageFrame(c);
- supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester);
+ supervisor.SendThisMessageTo(cmds[0] + PString(" ") + c->GetOurId(),
+ requester);
}
Comms * Manager::RemoveFromPreCallQueue(const PString & preferredId)
Modified: sofaswitch/trunk/am/manager.h
==============================================================================
--- sofaswitch/trunk/am/manager.h (original)
+++ sofaswitch/trunk/am/manager.h Sun Jul 27 00:47:16 2008
@@ -104,7 +104,7 @@
/**Allocate a new ID, place it in the pending list
(nodesMakingNewCalls) and reply with the id to the controller
who made this request */
- void RequestNewId(const PString & requester);
+ void RequestNewId(const PStringArray & cmds, const PString & requester);
/**The entry point, where the main control loop sits */
void Main();
Modified: sofaswitch/trunk/am/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/am/supervisor.cxx (original)
+++ sofaswitch/trunk/am/supervisor.cxx Sun Jul 27 00:47:16 2008
@@ -59,7 +59,7 @@
PTRACE(3, "end of this supervisor ");
}
-void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
PTRACE(0, "Should not called in the context of an AM");
}
@@ -73,7 +73,7 @@
PTRACE(3, "Destructor Supervisor thread has ended");
}
-void Supervisor::ProcessCallNode(PStringArray & cmds, PString & sender)
+void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender)
{
PTRACE(3, "Supervisor:: we can start a call to " << sender);
if (cmds.GetSize() < 2) {
@@ -83,7 +83,7 @@
}
}
-void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
Manager *mgr = AmProcess::Current().GetManager();
PStringStream status;
@@ -104,17 +104,17 @@
}
-void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" We are the supervisor for the Sofa Switch Answering Machine"), sender);
}
-void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender);
}
-void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender)
{
SetRemoteController(sender);
PTRACE(3, "Supervisor says::End everything now");
@@ -122,9 +122,9 @@
PTRACE(3, "Supervisor says::End everything now, and it has been initiated.");
}
-void Supervisor::ProcessRequestNewId(PStringArray &/*cmds*/, PString & sender)
+void Supervisor::ProcessRequestNewId(const PStringArray & cmds, const PString & sender)
{
- AmProcess::Current().GetManager()->RequestNewId(sender);
+ AmProcess::Current().GetManager()->RequestNewId(cmds, sender);
}
void Supervisor::SilentlyEndAll()
Modified: sofaswitch/trunk/am/supervisor.h
==============================================================================
--- sofaswitch/trunk/am/supervisor.h (original)
+++ sofaswitch/trunk/am/supervisor.h Sun Jul 27 00:47:16 2008
@@ -63,7 +63,7 @@
protected:
/**we have received a command advising us how to answer to the
incoming call, so we act as required and reply accordingly*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**The supervisor has completed. This method is called when this
supervisor instance terminates. Since there is only one
@@ -72,26 +72,26 @@
/**we have received a Call other Node command, so do it and reply
accordingly*/
- virtual void ProcessCallNode(PStringArray & cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray & cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly*/
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us that we are to end now */
- virtual void ProcessQuitNow(PStringArray &cmds, PString & sender);
+ virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to provide the id of a new
communications nodes, that will be controlled only by the remote
node */
- virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender);
+ virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender);
/**Some MessageFrame instances do not have the permission to quit
now. This virtual method determines if this instance is permitted to
Modified: sofaswitch/trunk/mcu/comms.cxx
==============================================================================
--- sofaswitch/trunk/mcu/comms.cxx (original)
+++ sofaswitch/trunk/mcu/comms.cxx Sun Jul 27 00:47:16 2008
@@ -66,7 +66,7 @@
new CommsConsumer(manager, this);
}
-void Comms::ProcessTransferUdp(PStringArray &cmds, PString & sender)
+void Comms::ProcessTransferUdp(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "Set media connection pointer of comms to be frame ");
@@ -88,7 +88,7 @@
SendThisMessageTo(advise, remoteController);
}
-void Comms::ProcessHangup(PStringArray &cmds, PString & sender)
+void Comms::ProcessHangup(const PStringArray &cmds, const PString & sender)
{
/* First step in the destruction of this Comms instance.
Note that there are two ways a comms instance can be closed down.
@@ -132,7 +132,7 @@
audioWriteThread.Terminate();
}
-void Comms::ProcessCallNode(PStringArray &cmds, PString & sender)
+void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "One Unqiue Id:: we can start a call (controlled by " << sender << ")");
if (cmds.GetSize() < 2) {
@@ -144,7 +144,7 @@
// manager.StartCall(cmds[1], sender, GetOurId());
}
-void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "Coms::ProcessStatusQuery");
PSafePtr <Member> member = manager.activeMembers.FindWithLock(GetOurId(), PSafeReadOnly);;
@@ -166,7 +166,7 @@
SendThisMessageTo(status, sender);
}
-void Comms::ProcessDuration(PStringArray &cmds, PString & sender)
+void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender)
{
PString duration = GetDurationInfo();
SendThisMessageTo(duration, sender);
@@ -194,19 +194,19 @@
return member->GetDurationInfo();
}
-void Comms::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
PStringStream message;
message << "Sofa Switch Answering Machine for call " + GetOurId();
SendThisMessageTo(message, sender);
}
-void Comms::ProcessDebug(PStringArray &cmds, PString & sender)
+void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender);
}
-void Comms::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
PTRACE(3, "We answer this call automatically, so thankyou");
}
Modified: sofaswitch/trunk/mcu/comms.h
==============================================================================
--- sofaswitch/trunk/mcu/comms.h (original)
+++ sofaswitch/trunk/mcu/comms.h Sun Jul 27 00:47:16 2008
@@ -101,13 +101,13 @@
transferred, we move ourselves out of the Manager's list of
pending calls. Then we call the ancestor method to actually do
the work of transferring the udp */
- virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender);
+ virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender);
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a Call other Node command, so do it and reply accordingly*/
- virtual void ProcessCallNode(PStringArray &cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly.
@@ -117,7 +117,7 @@
first structure may have changed. Consequently, it does happen where
the counts of the instances of different classes is not
consistant. */
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**Get information (in a textual form) of how long this call has been up */
PString GetDurationInfo();
@@ -128,19 +128,19 @@
/**we have received a command queryig the current call duration ,
so extract information & answer */
- virtual void ProcessDuration(PStringArray &cmds, PString & sender);
+ virtual void ProcessDuration(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us how to answer to the
incoming call, so we act as required and reply accordingly*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**Send this dtmf string to the remote node. Returns true on
success, false on failure. */
Modified: sofaswitch/trunk/mcu/conferenceroom.cxx
==============================================================================
--- sofaswitch/trunk/mcu/conferenceroom.cxx (original)
+++ sofaswitch/trunk/mcu/conferenceroom.cxx Sun Jul 27 00:47:16 2008
@@ -43,7 +43,7 @@
PTRACE(3, "ConferenceRoom\tConstructor for " << *this);
}
-void ConferenceRoom::PrintOn(ostream & strm ) const
+void ConferenceRoom::PrintOn(ostream & strm ) const
{
strm << "Conference Room " << roomId;
}
@@ -53,7 +53,7 @@
PTRACE(3, "ConferenceRoom\tDestructor for " << *this);
}
-void ConferenceRoom::RemoveMember(PString memberId)
+void ConferenceRoom::RemoveMember(const PString & memberId)
{
PWaitAndSignal m(memberListLock);
@@ -92,7 +92,7 @@
return participants;
}
-PStringList ConferenceRoom::AddNewMember(PString memberId)
+PStringList ConferenceRoom::AddNewMember(const PString & memberId)
{
PTRACE(3, "Add member " << memberId << " to " << roomId);
PWaitAndSignal m(memberListLock);
Modified: sofaswitch/trunk/mcu/conferenceroom.h
==============================================================================
--- sofaswitch/trunk/mcu/conferenceroom.h (original)
+++ sofaswitch/trunk/mcu/conferenceroom.h Sun Jul 27 00:47:16 2008
@@ -76,12 +76,12 @@
PString GetRoomId() { return roomId; }
/**Remove a member from this list of members */
- void RemoveMember(PString memberId);
+ void RemoveMember(const PString & memberId);
/**Add a member to this list of members.
@return the list of members in this room, prior to addition.*/
- PStringList AddNewMember(PString memberId);
+ PStringList AddNewMember(const PString & memberId);
/**pretty print information this ConferenceRoom */
virtual void PrintOn(ostream & strm /// Stream to output text representation
Modified: sofaswitch/trunk/mcu/manager.cxx
==============================================================================
--- sofaswitch/trunk/mcu/manager.cxx (original)
+++ sofaswitch/trunk/mcu/manager.cxx Sun Jul 27 00:47:16 2008
@@ -197,11 +197,10 @@
activeRooms.RemoveAt(conferenceRoomId);
}
-void Manager::RequestNewId(const PString & requester, PStringArray &cmd)
+void Manager::RequestNewId(const PStringArray &cmd, const PString & requester)
{
PTRACE(3, "Manager\t request room " << cmd[1] << " and an id");
- PString roomId = cmd[1];
-
+ PString roomId = cmd[1];
{
PWaitAndSignal m(activeRooms.GetMutex()); /**Prevent adding two conferences of same name */
PSafePtr <ConferenceRoom> room = activeRooms.FindWithLock(roomId, PSafeReadOnly);
@@ -225,8 +224,9 @@
if (c == NULL)
return;
- /* The next line of code ensures there will be a message, generated by the server,
- sent to the node specified in requester when c dies. */
+ /* The next line of code ensures there will be a message, generated
+ by the server, sent to the node specified in requester when c
+ dies. */
c->SetRemoteController(requester);
PTRACE(3, "Prior Create Member, size is " << activeMembers.GetSize());
@@ -239,8 +239,7 @@
PTRACE(3, "Have created member, " << c->GetOurId() << " and filled membership list");
nodesMakingCalls.AddNewMessageFrame(c);
- supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester);
- PTRACE(3, "Created Member, size is now " << activeMembers.GetSize());
+ supervisor.SendThisMessageTo(cmd[0] + PString(" ") + c->GetOurId(), requester);
}
Comms * Manager::RemoveFromPreCallQueue(const PString & preferredId)
@@ -270,7 +269,7 @@
return c;
}
-PString Manager::ProcessStatusQuery(PStringArray & cmds)
+PString Manager::ProcessStatusQuery(const PStringArray & cmds)
{
PStringStream result;
Modified: sofaswitch/trunk/mcu/manager.h
==============================================================================
--- sofaswitch/trunk/mcu/manager.h (original)
+++ sofaswitch/trunk/mcu/manager.h Sun Jul 27 00:47:16 2008
@@ -100,7 +100,8 @@
and reply with the id to the controller who made this request. Also
causes a PSafePtr<Member> to be added to the activeMembers list in a
threadsafe fashion. */
- void RequestNewId(const PString & requester, PStringArray & cmds);
+ void RequestNewId(const PStringArray & cmds, const PString & requester);
+
/**Cause the PSafePtr<Member> of the specified id to be removed from the
* activeMembers list in a threadsafe fashion */
@@ -134,7 +135,7 @@
void WaitForSupervisorEnd();
/**Get the status on all conferences, or just one conference */
- PString ProcessStatusQuery(PStringArray & cmds);
+ PString ProcessStatusQuery(const PStringArray & cmds);
/**Cause the comms instance in activeCalls to be removed from this
list. This is an action which is part of the shut down
Modified: sofaswitch/trunk/mcu/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/mcu/supervisor.cxx (original)
+++ sofaswitch/trunk/mcu/supervisor.cxx Sun Jul 27 00:47:16 2008
@@ -55,7 +55,7 @@
PTRACE(3, "end of this supervisor ");
}
-void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
PAssertAlways("ProcessAnswer Should not called in the context of an MCU");
}
@@ -65,7 +65,7 @@
PTRACE(3, "Supervisor thread has ended");
}
-void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
PString status;
status = McuProcess::Current().GetManager()->ProcessStatusQuery(cmds);
@@ -74,17 +74,17 @@
}
-void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" We are the supervisor for the Sofa Switch Answering Machine"), sender);
}
-void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender);
}
-void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender)
{
SetRemoteController(sender);
PTRACE(3, "Supervisor says::End everything now");
@@ -92,27 +92,23 @@
}
-void Supervisor::ProcessHangup(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessHangup(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" is not handled by the supervisor - send it to the relevant call "), sender);
}
-void Supervisor::ProcessRequestNewId(PStringArray & cmds, PString & sender)
+void Supervisor::ProcessRequestNewId(const PStringArray & cmds, const PString & sender)
{
- PStringStream commands;
- for (PINDEX i = 0; i < cmds.GetSize(); i++)
- commands << cmds[i] << " ";
- PTRACE(3, "Supervisor:ProcessRequestNewId :: " << commands);
-
if (cmds.GetSize() < 2) {
PStringStream strm;
- strm << cmds;
- PTRACE(3, "Ignore this request new id as no room specified " << strm);
+ strm << "Ignore this request new id as no room specified " << cmds;
+ SendThisMessageTo(strm, sender);
+ PTRACE(3, strm);
return;
}
- McuProcess::Current().GetManager()->RequestNewId(sender, cmds);
+ McuProcess::Current().GetManager()->RequestNewId(cmds, sender);
}
void Supervisor::SilentlyEndAll()
Modified: sofaswitch/trunk/mcu/supervisor.h
==============================================================================
--- sofaswitch/trunk/mcu/supervisor.h (original)
+++ sofaswitch/trunk/mcu/supervisor.h Sun Jul 27 00:47:16 2008
@@ -64,7 +64,7 @@
call, so we act as required and reply accordingly. The mcu does not
actually handle this at the moment. We are required to declare this
method, as ProcessAnswer is pure, in the ancestor.*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**The supervisor has completed. This method is called when this
supervisor instance terminates. Since there is only one
@@ -72,7 +72,7 @@
virtual void OnTermination();
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly
@@ -82,23 +82,23 @@
first structure may have changed. Consequently, it does happen where
the counts of the instances of different classes is not
consistant. */
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us that we are to end now */
- virtual void ProcessQuitNow(PStringArray &cmds, PString & sender);
+ virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to provide the id of a new
communications nodes, that will be controlled only by the remote
node */
- virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender);
+ virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender);
/**Some MessageFrame instances do not have the permission to quit
now. This virtual method determines if this instance is permitted to
Modified: sofaswitch/trunk/sofa/include/sofa/messages.h
==============================================================================
--- sofaswitch/trunk/sofa/include/sofa/messages.h (original)
+++ sofaswitch/trunk/sofa/include/sofa/messages.h Sun Jul 27 00:47:16 2008
@@ -167,47 +167,47 @@
/**We have a message come in from the server, and it ends up here.
Now, handle this message, and give it to the relevant method below */
- virtual void ProcessMessage(PString & message,
- PString & sender);
+ virtual void ProcessMessage(const PString & message,
+ const PString & sender);
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a Call other Node command, so do it and reply
accordingly*/
- virtual void ProcessCallNode(PStringArray &cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply
accordingly*/
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a Query Local Address & port command, so reply
accordingly*/
- virtual void ProcessQueryLocalAddress(PStringArray &cmds, PString & sender);
+ virtual void ProcessQueryLocalAddress(const PStringArray &cmds, const PString & sender);
/**we have received a Query on the Destination Address & port, so reply
accordingly*/
- virtual void ProcessQueryDestAddress(PStringArray &cmds, PString & sender);
+ virtual void ProcessQueryDestAddress(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us of the address & port to
send to, so store this information and reply accordingly*/
- virtual void ProcessAdviseSendAddress(PStringArray &cmds, PString & sender);
+ virtual void ProcessAdviseSendAddress(const PStringArray &cmds, const PString & sender);
/**we have received a command queryig the current call duration ,
so extract information & answer */
- virtual void ProcessDuration(PStringArray &cmds, PString & sender);
+ virtual void ProcessDuration(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us how to answer to the
incoming call, so we act as required and reply accordingly*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender) = 0;
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender) = 0;
/**we have received a command advising us that we are to install udp
comms with a particular remote node id. Now, we have to reply
@@ -224,29 +224,29 @@
Although, a supervisor, which watchs lots of calls, will override this
and treat it as an error on receiving this comand.*/
- virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender);
+ virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us that we are to end now */
- virtual void ProcessQuitNow(PStringArray &cmds, PString & sender);
+ virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to list the available commands */
- virtual void ProcessHelp(PStringArray &cmds, PString & sender);
+ virtual void ProcessHelp(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to send the dtmf chars.
An application would not normally override this method.*/
- virtual void ProcessSendDtmf(PStringArray &cmds, PString & sender);
+ virtual void ProcessSendDtmf(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to provide the id of a new
communications nodes, that will be controlled only by the
remote node */
- virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender);
+ virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender);
/**We have received a command asking us to set the file that we
fill with audio data. This file will (normally) be empty. An
application would not override this method, as this mthod does
check that a file name is provided. This method will call
SetReadFile, which the application will override */
- virtual void ProcessSetWriteFile(PStringArray &cmds, const PString & sender);
+ virtual void ProcessSetWriteFile(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to set the file that we
read from and then transmit over ethernet to the remote
@@ -255,14 +255,14 @@
method, as this mthod does check that a file name is
provided. This method will call SetWriteFile, which the
application will override */
- virtual void ProcessSetReadFile(PStringArray &cmds, const PString & sender);
+ virtual void ProcessSetReadFile(const PStringArray &cmds, const PString & sender);
#ifdef PMEMORY_CHECK
/**we have received a command asking us to write all current
allocations to the specified file. This command checks the the
file is specified in the command line. If specified, all
objects are dumped to that file.*/
- virtual void ProcessMemoryDump(PStringArray &cmds, PString & sender);
+ virtual void ProcessMemoryDump(const PStringArray &cmds, const PString & sender);
#endif
/**Actually set the file that we write audio to. We will fill this
Modified: sofaswitch/trunk/sofa/src/messages.cxx
==============================================================================
--- sofaswitch/trunk/sofa/src/messages.cxx (original)
+++ sofaswitch/trunk/sofa/src/messages.cxx Sun Jul 27 00:47:16 2008
@@ -433,8 +433,8 @@
writeMessageLock.Signal();
}
-void MessageFrame::ProcessMessage(PString & message,
- PString & sender)
+void MessageFrame::ProcessMessage(const PString & message,
+ const PString & sender)
{
lastSender = sender;
PStringArray cmds = message.Tokenise(" ", false);
@@ -537,7 +537,9 @@
return;
}
- if (cmds[0] *= availableCommands[14]) {
+ /* The RequestNewId command can come as REQUESTNEWID_IdentityString,
+ where the IdentityString labels where the newid answer is handled*/
+ if (cmds[0].Left(12) *= availableCommands[14]) {
PTRACE(4, "ProcessRequestNewId " << cmds[0]);
ProcessRequestNewId(cmds, sender);
return;
@@ -572,22 +574,22 @@
PTRACE(3, PString("The command ") + cmds[0] + " was not understood");
}
-void MessageFrame::ProcessHangup(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessHangup(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessCallNode(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessCallNode(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessQueryLocalAddress(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessQueryLocalAddress(const PStringArray &cmds, const PString & sender)
{
PINDEX portNo;
PIPSocket::Address addr;
@@ -599,7 +601,7 @@
SendThisMessageTo(cmds[0] + PString(" ") + addr.AsString() + PString(":") + PString(portNo), sender);
}
-void MessageFrame::ProcessQueryDestAddress(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessQueryDestAddress(const PStringArray &cmds, const PString & sender)
{
PINDEX portNo;
PIPSocket::Address addr;
@@ -611,7 +613,7 @@
SendThisMessageTo(cmds[0] + PString(" ") + addr.AsString() + PString(":") + PString(portNo), sender);
}
-void MessageFrame::ProcessAdviseSendAddress(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessAdviseSendAddress(const PStringArray &cmds, const PString & sender)
{
if (cmds.GetSize() < 2) {
PTRACE(3, "failed to specify destination port & address");
@@ -639,17 +641,17 @@
return;
}
-void MessageFrame::ProcessDuration(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessDuration(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessIdentify(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessDebug(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
@@ -662,7 +664,7 @@
}
*/
-void MessageFrame::ProcessTransferUdp(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessTransferUdp(const PStringArray &cmds, const PString & sender)
{
if (cmds.GetSize() < 2) {
PTRACE(3, cmds[0] << " Failed - too few commands" << sender);
@@ -728,12 +730,12 @@
}
-void MessageFrame::ProcessQuitNow(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessQuitNow(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender);
}
-void MessageFrame::ProcessHelp(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessHelp(const PStringArray &cmds, const PString & sender)
{
PString reply;
@@ -775,7 +777,7 @@
return false;
}
-void MessageFrame::ProcessSendDtmf(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessSendDtmf(const PStringArray &cmds, const PString & sender)
{
if (cmds.GetSize() < 2) {
PTRACE(3, cmds[0] << " Failed - dtmf chars not supplied" << sender);
@@ -787,13 +789,13 @@
}
}
-void MessageFrame::ProcessRequestNewId(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessRequestNewId(const PStringArray &cmds, const PString & sender)
{
PTRACE(1, cmds[0] <<" is not implmented");
}
-void MessageFrame::ProcessSetReadFile(PStringArray &cmds, const PString & sender)
+void MessageFrame::ProcessSetReadFile(const PStringArray &cmds, const PString & sender)
{
if (cmds.GetSize() != 2) {
PTRACE(3, cmds[0] << " Failed - Read file not correctly specified"
@@ -804,7 +806,7 @@
SetReadFile(cmds[1]);
}
-void MessageFrame::ProcessSetWriteFile(PStringArray &cmds, const PString & sender)
+void MessageFrame::ProcessSetWriteFile(const PStringArray &cmds, const PString & sender)
{
if (cmds.GetSize() != 2) {
PStringStream error;
@@ -820,7 +822,7 @@
#ifdef PMEMORY_CHECK
-void MessageFrame::ProcessMemoryDump(PStringArray &cmds, PString & sender)
+void MessageFrame::ProcessMemoryDump(const PStringArray &cmds, const PString & sender)
{
PMemoryHeap::DumpObjectsSince(memoryState);
Modified: sofaswitch/trunk/voip/comms.cxx
==============================================================================
--- sofaswitch/trunk/voip/comms.cxx (original)
+++ sofaswitch/trunk/voip/comms.cxx Sun Jul 27 00:47:16 2008
@@ -86,7 +86,7 @@
PTRACE(3, "END of comms communications for " << GetOurId());
}
-void Comms::ProcessHangup(PStringArray &/*cmds*/, PString & /*sender*/)
+void Comms::ProcessHangup(const PStringArray &/*cmds*/, const PString & /*sender*/)
{
PTRACE(3, "Process hangup message");
PWaitAndSignal m(opalCallLock);
@@ -100,7 +100,7 @@
PTRACE(3, "Silently end all, which is \"ignored\"");
}
-void Comms::ProcessCallNode(PStringArray &cmds, PString & sender)
+void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender)
{
{
PWaitAndSignal m(opalCallLock);
@@ -122,7 +122,7 @@
manager.StartCall(cmds[1], sender, GetOurId());
}
-void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
opalCallLock.Wait();
if (myOpalCall == NULL) {
@@ -137,7 +137,7 @@
}
-void Comms::ProcessDuration(PStringArray &cmds, PString & sender)
+void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender)
{
opalCallLock.Wait();
if (myOpalCall == NULL) {
@@ -152,17 +152,17 @@
SendThisMessageTo(duration, sender);
}
-void Comms::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(PString("Voip endpoint for one call ") + GetOurId(), sender);
}
-void Comms::ProcessDebug(PStringArray &cmds, PString & sender)
+void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender);
}
-void Comms::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
{
PWaitAndSignal m(opalCallLock);
Modified: sofaswitch/trunk/voip/comms.h
==============================================================================
--- sofaswitch/trunk/voip/comms.h (original)
+++ sofaswitch/trunk/voip/comms.h Sun Jul 27 00:47:16 2008
@@ -114,29 +114,29 @@
virtual void OnTermination();
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a Call other Node command, so do it and reply accordingly*/
- virtual void ProcessCallNode(PStringArray &cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly*/
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a command queryig the current call duration ,
so extract information & answer */
- virtual void ProcessDuration(PStringArray &cmds, PString & sender);
+ virtual void ProcessDuration(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us how to answer to the
incoming call, so we act as required and reply accordingly*/
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**Send this dtmf string to the remote node. Returns true on
success, false on failure. */
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 27 00:47:16 2008
@@ -635,7 +635,8 @@
return duration;
}
-void MyManager::RequestNewId(PString & requester)
+void MyManager::RequestNewId(const PStringArray & cmds,
+ const PString & requester)
{
Comms *c;
PINDEX attempt = 0;
@@ -646,6 +647,7 @@
attempt++;
}
if (attempt >= 10) {
+ supervisor.SendThisMessageTo(cmds[0] + PString(" failed sorry."), requester);
cerr << "not good - tried hard to make a running comms" << endl;
cerr << "Give up now" << endl;
return;
@@ -653,7 +655,7 @@
c->SetRemoteController(requester);
nodesMakingCalls.AddNewMessageFrame(c);
- supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester);
+ supervisor.SendThisMessageTo(cmds[0] + PString(" ") + c->GetOurId(), requester);
}
bool MyManager::SendThisDtmf(const PString & token, const PString & thisDtmf)
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Sun Jul 27 00:47:16 2008
@@ -208,7 +208,8 @@
/**Start the proces to get a new ID. The new ID is created by a
separate thread, and the remote controller is advised when it
is available */
- void RequestNewId(PString & requester);
+ void RequestNewId(const PStringArray & cmds,
+ const PString & requester);
/**Check the different lists of Comms instances in this Manager
(runningComms, deadComms, and nodesMakingCalls) and find the
Modified: sofaswitch/trunk/voip/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/voip/supervisor.cxx (original)
+++ sofaswitch/trunk/voip/supervisor.cxx Sun Jul 27 00:47:16 2008
@@ -83,17 +83,17 @@
#endif
}
-void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender)
{
PAssertAlways("Supervisor should not attempt to answer a call");
}
-void Supervisor::ProcessTransferUdp(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessTransferUdp(const PStringArray &cmds, const PString & sender)
{
PAssertAlways("Supervisor should not attempt to transfer a call");
}
-void Supervisor::ProcessCallNode(PStringArray & cmds, PString & sender)
+void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender)
{
PTRACE(3, "Supervisor:: we can start a call to " << sender);
if (cmds.GetSize() < 2) {
@@ -106,7 +106,7 @@
VoipProcess::Current().GetManager()->StartCall(cmds[1], sender, anyCommsId);
}
-void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender)
{
PStringStream status;
if (cmds.GetSize() >= 2) {
@@ -119,17 +119,17 @@
}
-void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" We are the opal supervisor"), sender);
}
-void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender)
{
SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender);
}
-void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender)
{
SetRemoteController(sender);
PTRACE(3, "Supervisor says::End everything now");
@@ -143,15 +143,16 @@
VoipProcess::Current().GetManager()->EndEverything();
}
-void Supervisor::ProcessHangup(PStringArray &cmds, PString & sender)
+void Supervisor::ProcessHangup(const PStringArray &cmds, const PString & sender)
{
PAssertAlways("Supervisor should not process a Hangup message");
}
-void Supervisor::ProcessRequestNewId(PStringArray &/*cmds*/, PString & sender)
+void Supervisor::ProcessRequestNewId(const PStringArray & cmds,
+ const PString & sender)
{
- VoipProcess::Current().GetManager()->RequestNewId(sender);
+ VoipProcess::Current().GetManager()->RequestNewId(cmds, sender);
}
bool Supervisor::ProcessDescendantCommands(const PStringArray & cmds,
Modified: sofaswitch/trunk/voip/supervisor.h
==============================================================================
--- sofaswitch/trunk/voip/supervisor.h (original)
+++ sofaswitch/trunk/voip/supervisor.h Sun Jul 27 00:47:16 2008
@@ -81,36 +81,37 @@
virtual void OnTermination();
/**we have received a hangup message, so end the call */
- virtual void ProcessHangup(PStringArray &cmds, PString & sender);
+ virtual void ProcessHangup(const PStringArray &cmds, const PString & sender);
/**we have received a Call other Node command, so do it and reply accordingly*/
- virtual void ProcessCallNode(PStringArray & cmds, PString & sender);
+ virtual void ProcessCallNode(const PStringArray & cmds, const PString & sender);
/**This method is overridden as an error handler. The supervisor should never
receive this message */
- void ProcessTransferUdp(PStringArray &cmds, PString & sender);
+ void ProcessTransferUdp(const PStringArray &cmds, const PString & sender);
/**we have received a query status command, so do it and reply accordingly*/
- virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender);
+ virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender);
/**we have received a command requesting that we identify ourselves
so do it and reply accordingly*/
- virtual void ProcessIdentify(PStringArray &cmds, PString & sender);
+ virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender);
/**we have received a command which enables/disables debug
information so install as required and reply accordingly*/
- virtual void ProcessDebug(PStringArray &cmds, PString & sender);
+ virtual void ProcessDebug(const PStringArray &cmds, const PString & sender);
/**we have received a command advising us that we are to end now */
- virtual void ProcessQuitNow(PStringArray &cmds, PString & sender);
+ virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender);
/**we have received a command asking us to provide the id of a new
communications nodes, that will be controlled only by the remote
node */
- virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender);
+ virtual void ProcessRequestNewId(const PStringArray &cmds,
+ const PString & sender);
/**Placed here - the child class has this method as pure virtual... */
- virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender);
/**Report to the sender the status of the lists in the iax portion of opal. */
virtual void ProcessIaxStatus(const PStringArray &cmds, const PString & sender);
1
0
[Sofaswitch-svn] [commit] r432 - in sofaswitch/trunk: callflow/src sofa/include/sofa sofa/src voip
by SofaSWITCH SVN 25 Jul '08
by SofaSWITCH SVN 25 Jul '08
25 Jul '08
Author: derek
Date: Fri Jul 25 01:00:20 2008
New Revision: 432
Modified:
sofaswitch/trunk/callflow/src/callstartstop.cpp
sofaswitch/trunk/callflow/src/endcall.cpp
sofaswitch/trunk/callflow/src/transfermedia.cpp
sofaswitch/trunk/sofa/include/sofa/messages.h
sofaswitch/trunk/sofa/src/messages.cxx
sofaswitch/trunk/voip/comms.cxx
sofaswitch/trunk/voip/comms.h
sofaswitch/trunk/voip/counts.cxx
sofaswitch/trunk/voip/counts.h
sofaswitch/trunk/voip/jocall.cxx
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
sofaswitch/trunk/voip/supervisor.cxx
Log:
Lots of tidy ups to improve the efficiency of the voip subsystem.
Minor cleanups to callflow to make it more robust.
Modified: sofaswitch/trunk/callflow/src/callstartstop.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/callstartstop.cpp (original)
+++ sofaswitch/trunk/callflow/src/callstartstop.cpp Fri Jul 25 01:00:20 2008
@@ -64,6 +64,18 @@
file.AddLine(wxT(" try: "));
file.AddLine(wxT(" self.rhost = eval(self.data[a][\"worker node\"]) "));
file.AddLine(wxT(" except: "));
+ switch (kind) {
+ case MakeCall:
+ file.AddLine(wxT(" print \"Attempting to make a call \""));
+ break;
+ case EndCall:
+ file.AddLine(wxT(" print \"Attempting to end a call \""));
+ break;
+ case AcceptCall:
+ file.AddLine(wxT(" print \"Attempting to accept a call \" "));
+ break;
+ default:;
+ }
file.AddLine(wxT(" print \"The worker node string \", self.data[a][\"worker node\"], \" could not be evaluated as a Python string\" "));
file.AddLine(wxT(" self.rhost = \"\" "));
if (kind == MakeCall) {
Modified: sofaswitch/trunk/callflow/src/endcall.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/endcall.cpp (original)
+++ sofaswitch/trunk/callflow/src/endcall.cpp Fri Jul 25 01:00:20 2008
@@ -22,10 +22,6 @@
{
}
-
-
-
-
void DndShapeEndCall::Draw(wxDC & dc)
{
DndShapeCallStartStop::Draw(dc);
Modified: sofaswitch/trunk/callflow/src/transfermedia.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/transfermedia.cpp (original)
+++ sofaswitch/trunk/callflow/src/transfermedia.cpp Fri Jul 25 01:00:20 2008
@@ -69,24 +69,26 @@
bool DndShapeTransferMedia::WriteSystemCode(wxTextFile & file)
{
- file.AddLine(wxT(" def Transfer_Media(self, sTuple): "));
- file.AddLine(wxT(" a,b,c = sTuple "));
- file.AddLine(wxT(" self.tMedia = self.data[a][\"worker node\"] "));
- file.AddLine(wxT(" try: "));
- file.AddLine(wxT(" self.rhost = eval(self.tMedia) "));
- file.AddLine(wxT(" except: "));
- file.AddLine(wxT(" print \"The Worker node Python \", self.tMedia, \" could not be evaluated\" "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
-
- file.AddLine(wxT(" self.wNode = self.data[a][\"worker receiver\"] "));
- file.AddLine(wxT(" try: "));
- file.AddLine(wxT(" self.rhost += \":TRANSFERUDP \" + eval(self.wNode) + \"\\0\" "));
- file.AddLine(wxT(" except: "));
- file.AddLine(wxT(" print \"The node to transfer media to \", self.wNode, \" could not be evaluated\" "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+ file.AddLine(wxT(" def Transfer_Media(self, sTuple): "));
+ file.AddLine(wxT(" a,b,c = sTuple "));
+ file.AddLine(wxT(" self.tMedia = self.data[a][\"worker node\"] "));
+ file.AddLine(wxT(" self.wNode = self.data[a][\"worker receiver\"] "));
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" self.rhost = eval(self.tMedia) "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"The transfer media node Python \", self.tMedia, \" could not be evaluated\""));
+ file.AddLine(wxT(" print \"Unsure on the validity of the string \", self.wNode, \" as yet\" "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" self.rhost += \":TRANSFERUDP \" + eval(self.wNode) + \"\\0\" "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"The node to transfer media to \", self.wNode, \" could not be evaluated\" "));
+ file.AddLine(wxT(" print \"However, python did evaluate \", self.tMedia, \" just fine\" "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
- file.AddLine(wxT(" self.transport.write(self.rhost) "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+ file.AddLine(wxT(" self.transport.write(self.rhost) "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
file.AddLine(wxT(""));
return true;
Modified: sofaswitch/trunk/sofa/include/sofa/messages.h
==============================================================================
--- sofaswitch/trunk/sofa/include/sofa/messages.h (original)
+++ sofaswitch/trunk/sofa/include/sofa/messages.h Fri Jul 25 01:00:20 2008
@@ -368,12 +368,6 @@
#endif
private:
- /**Close the messages socket, and send a terminating message to
- the remote controller. Only this class can close this
- socket. This helps to ensure it is closed down at the end of
- all comms.*/
- void CloseMessagesSocket();
-
/**Keep a reference of the class responsible for creating new
unique IDs, which are derived from the supplied node Id..*/
LaunchNewId & lid;
Modified: sofaswitch/trunk/sofa/src/messages.cxx
==============================================================================
--- sofaswitch/trunk/sofa/src/messages.cxx (original)
+++ sofaswitch/trunk/sofa/src/messages.cxx Fri Jul 25 01:00:20 2008
@@ -145,14 +145,6 @@
SendThisMessageTo(PString("RECEIVEDDTMF ") + receivedDtmf, GetRemoteController());
}
-void MessageFrame::CloseMessagesSocket()
-{
- PTRACE(3, "Close messages socket for " << GetOurId());
-
- PThread::Sleep(100); //Let the message be sent, then close the socket.
- messagesSocket.Close();
-}
-
bool MessageFrame::WaitUntilInitialised()
{
PTRACE(3, "WaitForInitialised start");
@@ -188,7 +180,7 @@
{
keepGoing = false;
audioSocket.Close();
- CloseMessagesSocket();
+ messagesSocket.Close();
threadRunning.Signal();
goodConnection.Signal();
writeSourceId.Signal();
@@ -350,7 +342,7 @@
}
PTRACE(3, "End of Process Incoming Messages - thread has finished");
- CloseMessagesSocket();
+ messagesSocket.Close();
OnTermination();
return;
@@ -452,7 +444,7 @@
if (OkToHangup()) {
keepGoing = false;
ProcessHangup(cmds, sender);
- CloseMessagesSocket();
+ messagesSocket.Close();
} else {
SendThisMessageTo("This communications instance cannot hangup", sender);
PTRACE(2, "Hangup ignored, as we cannot hangup..");
@@ -519,7 +511,7 @@
if (OkToQuitNow()) {
keepGoing = false;
ProcessQuitNow(cmds, sender);
- CloseMessagesSocket();
+ messagesSocket.Close();
} else {
SendThisMessageTo("Insufficient Privilidgets to cause a shutdown", sender);
PTRACE(2, "Quitnow aborted, as insufficient priviledges");
Modified: sofaswitch/trunk/voip/comms.cxx
==============================================================================
--- sofaswitch/trunk/voip/comms.cxx (original)
+++ sofaswitch/trunk/voip/comms.cxx Fri Jul 25 01:00:20 2008
@@ -59,6 +59,7 @@
void Comms::OnOpalCallCleared()
{
PWaitAndSignal m(opalCallLock);
+ DecEstablished();
if (myOpalCall != NULL) {
myOpalCall->SafeDereference();
myOpalCall = NULL;
@@ -74,16 +75,10 @@
void Comms::SetMyOpalCallPtr(MyOpalCall *ptr)
{
- myOpalCall = ptr;
- ptr->SafeReference();
- opalCallToken = ptr->GetToken();
-}
-
-void Comms::StopAllCommunications()
-{
- PTRACE(5, "Comms StopAllComms Start " << GetOurId());
- Terminate();
- PTRACE(5, "Comms StopAllComms All done " << GetOurId());
+ IncEstablished();
+ myOpalCall = ptr;
+ ptr->SafeReference();
+ opalCallToken = ptr->GetToken();
}
void Comms::OnTermination()
@@ -105,12 +100,6 @@
PTRACE(3, "Silently end all, which is \"ignored\"");
}
-void Comms::CloseThisId()
-{
- audioSocket.Close();
- Terminate();
-}
-
void Comms::ProcessCallNode(PStringArray &cmds, PString & sender)
{
{
@@ -274,7 +263,7 @@
for(PINDEX i = 0; i < PAbstractList::GetSize(); i++) {
mf = (Comms *)PAbstractList::GetAt(i);
- new CommsConsumer(manager, mf);
+ new CommsConsumer(mf);
}
}
@@ -296,38 +285,26 @@
////////////////////////////////////////////////////////////////////////////////
-CommsConsumer::CommsConsumer(MyManager &_manager, Comms *m)
- :PThread(10000, AutoDeleteThread, LowPriority, "%X Comms delete"),
- manager(_manager),
+CommsConsumer::CommsConsumer(Comms *m)
+ :PThread(10000, AutoDeleteThread, NormalPriority, "%X Comms delete"),
comms(m)
{
PTRACE(2, "Create a Clear Comms Consumer to clear a comms instance " << m->GetOurId());
Resume();
}
-
-CommsConsumer::~CommsConsumer()
-{
- PTRACE(2, "Finish Clear Comms Consumer to clear a comms instance " << ourId);
-}
-
+
void CommsConsumer::Main()
{
if (comms == NULL)
return;
- comms->WaitForTermination();
+ comms->Terminate();
- ourId = comms->GetOurId();
- PTRACE(3, "START checking: look for " << ourId << " to appear in a manager list");
+ comms->WaitForTermination();
- Comms *c = manager.ClearCommsId(ourId);
- if (c != NULL) {
- PTRACE(3, "NOW delete comms instance " << ourId);
- PTRACE(3, "as we found it and have exclusive access to it");
- PTRACE(3, "and know that this thread has finished.");
- delete c;
- }
+ delete comms;
}
+
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 2 spaces. */
Modified: sofaswitch/trunk/voip/comms.h
==============================================================================
--- sofaswitch/trunk/voip/comms.h (original)
+++ sofaswitch/trunk/voip/comms.h Fri Jul 25 01:00:20 2008
@@ -70,10 +70,6 @@
/** Close down the handling of incoming message, and break the link to the MyOpalCall class
*/
~Comms();
-
- /**Send a message to the remote controller that we are closing down now */
- virtual void StopAllCommunications();
-
/**Send a message to the remote controller saying that we are created (and
established in the Opal sense of a connection). The id of this node is
appended to the message.
@@ -101,10 +97,6 @@
by control commands */
PUDPSocket &GetAudioSocket();
- /**Close this id off. Basically, tell the remote end we are closing,
- and stop the comms on the tcp socket. */
- void CloseThisId();
-
/**Retrieve the opal call token that opal has assigned to the
corresponding OpalCall */
PString GetOpalCallToken() { return opalCallToken; }
@@ -221,23 +213,15 @@
/**Constructer - create this class, which is given the Comms
instance to destroy. This consumer class then does the rest */
- CommsConsumer(MyManager & _manager, Comms *destroyMe);
-
- /**Destructor */
- ~CommsConsumer();
-
+ CommsConsumer(Comms *destroyMe);
+
/**Where this thread runs to do the work */
void Main();
protected:
- /**Reference to the class that knows everything about everything */
- MyManager & manager;
/**The instance we have to delete */
Comms *comms;
-
- /**The id associated with the comms instance we ahve to delete */
- PString ourId;
};
/////////////////////////////////////////////////////////////////////////////
Modified: sofaswitch/trunk/voip/counts.cxx
==============================================================================
--- sofaswitch/trunk/voip/counts.cxx (original)
+++ sofaswitch/trunk/voip/counts.cxx Fri Jul 25 01:00:20 2008
@@ -37,6 +37,7 @@
/////////////////////////////////////////////////////////////////////////////
PAtomicInteger countComms;
+PAtomicInteger countEstablished;
PAtomicInteger countMyManager;
PAtomicInteger countMyOpalCall;
PAtomicInteger countOpalUdpSsConnection;
@@ -45,6 +46,7 @@
PAtomicInteger countUdpSoundChannel;
PAtomicInteger countDelComms;
+PAtomicInteger countDelEstablished;
PAtomicInteger countDelMyManager;
PAtomicInteger countDelMyOpalCall;
PAtomicInteger countDelOpalUdpSsConnection;
@@ -61,6 +63,15 @@
return msg;
}
+PString GetCountEstablished()
+{
+ PStringStream msg;
+ msg << ::setw(6) << PString(countEstablished)
+ << ::setw(6) << PString(countDelEstablished)
+ << ::setw(6) << PString(countEstablished - countDelEstablished) << ::setw(0);
+ return msg;
+}
+
PString GetCountMyManager()
{
PStringStream msg;
@@ -117,6 +128,7 @@
}
void DecComms() { ++countDelComms; }
+void DecEstablished() { ++countDelEstablished; }
void DecMyManager() { ++countDelMyManager; }
void DecMyOpalCall() { ++countDelMyOpalCall; }
void DecOpalUdpSsConnection() { ++countDelOpalUdpSsConnection; }
@@ -125,6 +137,7 @@
void DecUdpSoundChannel() { ++countDelUdpSoundChannel; }
void IncComms() { ++countComms; }
+void IncEstablished() { ++countEstablished; }
void IncMyManager() { ++countMyManager; }
void IncMyOpalCall() { ++countMyOpalCall; }
void IncOpalUdpSsConnection() { ++countOpalUdpSsConnection; }
Modified: sofaswitch/trunk/voip/counts.h
==============================================================================
--- sofaswitch/trunk/voip/counts.h (original)
+++ sofaswitch/trunk/voip/counts.h Fri Jul 25 01:00:20 2008
@@ -41,39 +41,96 @@
+/**Decrement the count on the Audio Delay instances established */
void DecAudioDelay();
+
+/**Increment the count on the Audio Delay instances established */
void IncAudioDelay();
+
+/**Report the count on the Audio Delay instances established */
PString GetCountAudioDelay();
+/**Decrement the count on SofaSwitch Communication instances established */
void DecComms();
+
+/**Increment the count on SofaSwitch Communication instances established */
void IncComms();
+
+/**Reportt the count on SofaSwitch Communication instances established */
PString GetCountComms();
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. DECREMENT operation */
+void DecEstablished();
+
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. INCREMENT operation */
+void IncEstablished();
+
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. Report this variable. */
+PString GetCountEstablished();
+
+/**Decrement the count on SofaSwitch Manager instances established */
void DecMyManager();
+
+/**Increment the count on SofaSwitch Manager instances established */
void IncMyManager();
+
+/**Report the count on SofaSwitch Manager instances established */
PString GetCountMyManager();
+/**Decrement the count on SofaSwitch OpalCall instances established */
void DecMyOpalCall();
+
+/**Increment the count on SofaSwitch OpalCall instances established */
void IncMyOpalCall();
+
+/**Report the count on SofaSwitch OpalCall instances established */
PString GetCountMyOpalCall();
+/**Decrement the count on SofaSwitch Connection instances established */
void DecOpalUdpSsConnection();
+
+/**Increment the count on SofaSwitch Connection instances established */
void IncOpalUdpSsConnection();
+
+/**Report the count on SofaSwitch Connection instances established */
PString GetCountOpalUdpSsConnection();
+/**Decrement the count on SofaSwitch EndPoints established */
void DecOpalUdpSsEndPoint();
+
+/**Increment the count on SofaSwitch EndPoints established */
void IncOpalUdpSsEndPoint();
+
+/**Report the count on SofaSwitch EndPoints established */
PString GetCountOpalUdpSsEndPoint();
+/**Decrement the count on Supervisors established */
void DecSupervisor();
+
+/**Increment the count on Supervisors established */
void IncSupervisor();
+
+/**Report the count on Supervisors established */
PString GetCountSupervisor();
+/**Decrement the count on sound channel established */
void DecUdpSoundChannel();
+
+/**Increment the count on sound channel established */
void IncUdpSoundChannel();
+
+/**Report the count on sound channel established */
PString GetCountUdpSoundChannel();
+
+
#endif // _COUNTS_H
Modified: sofaswitch/trunk/voip/jocall.cxx
==============================================================================
--- sofaswitch/trunk/voip/jocall.cxx (original)
+++ sofaswitch/trunk/voip/jocall.cxx Fri Jul 25 01:00:20 2008
@@ -75,13 +75,8 @@
MyOpalCall::~MyOpalCall()
{
PTRACE(3, "Destructor for Opal Call " << GetToken() << " and " << comms.GetOurId());
- comms.StopAllCommunications();
-/* The comms instance must not self delete on completion. We stop the comms
- instance, and then we delete it (as we are finished with it) */
-
- comms.WaitForTermination();
- manager.AppendFinishedComms(commsPtr);
+ new CommsConsumer(commsPtr);
PTRACE(3, "MyOpalCall\t" << *this << " destroyed dead and gone");
DecMyOpalCall();
}
@@ -89,35 +84,14 @@
bool MyOpalCall::OnSetUp(OpalConnection & connection)
{
PTRACE(3, "Call\tOnSetUp " << connection);
-
- bool ok = false;
-
- if (!LockReadWrite()) {
- PTRACE(3, "failed to lock the read write");
- return false;
- }
-
- PTRACE(3, "ConnectionsActive has a size of "
- << connectionsActive.GetSize());
-
- UnlockReadWrite();
-
- PINDEX i = 1;
- for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReadOnly); conn != NULL; ++conn, i++) {
- PTRACE(3, "connection " << i << " is " << (*conn));
- }
for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReadOnly); conn != NULL; ++conn) {
PTRACE(3, "TRY " << (*conn));
if (conn != &connection) {
PTRACE(3, "Now do a setup");
- if (conn->SetUpConnection()) {
- PTRACE(3, "set up the connection ok ");
- ok = true;
- }
+ conn->SetUpConnection();
}
}
- PTRACE(2, "finished onsetup of connection/call and it gave " << 1);
return true;
}
@@ -214,7 +188,7 @@
void MyOpalCall::CloseThisId()
{
- comms.CloseThisId();
+ comms.Terminate();
}
PUDPSocket & MyOpalCall::GetAudioSocket()
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Fri Jul 25 01:00:20 2008
@@ -107,7 +107,6 @@
supervisor.Resume();
nodesMakingCalls.Initialise();
- nodesFinishedCalls.Initialise();
runningComms.SetPreAllocatedSize(10);
runningComms.Initialise();
@@ -463,9 +462,9 @@
void MyManager::AcceptThisCall(const PString & uniqueCallId, bool doAccept)
{
PTRACE(3, "Accept this call if we can find it " << uniqueCallId);
- PSafePtr<OpalCall> oCall = FindCallWithLock(uniqueCallId);
+ PSafePtr<OpalCall> oCall = FindCallWithLock(uniqueCallId, PSafeReadOnly);
if (oCall == NULL) {
- PTRACE(3, "Failed to accept call with a token of " << uniqueCallId);
+ PTRACE(3, "Failed to accept call with a token of ");
return;
}
@@ -478,7 +477,7 @@
PString MyManager::GetStatusInfo(const PString & token)
{
- PSafePtr<OpalCall> call = FindCallWithLock(token);
+ PSafePtr<OpalCall> call = FindCallWithLock(token, PSafeReadOnly);
if (call == NULL) {
return "Status unavailable as not in a call";
}
@@ -543,6 +542,8 @@
status << "--------------" << endl;
status << " Comms count is "
<< GetCountComms() << endl;
+ status << " Established count is "
+ << GetCountEstablished() << endl;
status << " MyManager count is "
<< GetCountMyManager() << endl;
status << " MyOpalCall count is "
@@ -619,25 +620,12 @@
return c;
}
- c = (Comms *)nodesFinishedCalls.GetMessageFrameOn(memberId);
- if (c != NULL) {
- PTRACE(3, "Clear comms Id on " << memberId << " for comms instances finished in a call");
- return c;
- }
-
return NULL;
}
-void MyManager::AppendFinishedComms(Comms *commsPtr)
-{
- PTRACE(3, "Manager\tThis comms instance has finished a call, and is about to DIE" << commsPtr->GetOurId());
- nodesFinishedCalls.AddNewMessageFrame(commsPtr);
- new CommsConsumer(*this, commsPtr);
-}
-
PString MyManager::GetDurationInfo(const PString & token)
{
- PSafePtr<OpalCall> call = FindCallWithLock(token);
+ PSafePtr<OpalCall> call = FindCallWithLock(token, PSafeReadOnly);
if (call == NULL) {
return "Duration unavailable as not in a call";
}
@@ -671,7 +659,7 @@
bool MyManager::SendThisDtmf(const PString & token, const PString & thisDtmf)
{
PTRACE(3, "MyManager\tSend this dtmf " << thisDtmf << " to call " << token);
- OpalCall *oCall = FindCallWithLock(token);
+ OpalCall *oCall = FindCallWithLock(token, PSafeReadOnly);
if (oCall == NULL) {
PTRACE(3, "MyManager\tSend this dtmf " << thisDtmf << " to call " << token << " FAILED - call not found");
return false;
@@ -981,7 +969,7 @@
/*
* Local Variables:
* mode:c
- * c-basic-offset:4
+ * c-basic-offset:2
* End:
*/
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Fri Jul 25 01:00:20 2008
@@ -256,14 +256,9 @@
deleted */
MessageFrameListPending nodesMakingCalls;
- /**A list of the nodes who have completed calls they are in. Frames will
- be deleted by the CommsConsumer class, which will fish the node out of
- this list and delete it. */
- MessageFrameList nodesFinishedCalls;
-
-
- /**A list of Comms instances that are known to have died. Comms instances will be
- removed from this list by the CommsConsumer class.*/
+ /**A list of Comms instances that are known to have died. Comms
+ instances will be removed from this list by the CommsConsumer
+ class.*/
MessageFrameList deadComms;
/**The sound system endpoint that we use to control talk to the
Modified: sofaswitch/trunk/voip/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/voip/supervisor.cxx (original)
+++ sofaswitch/trunk/voip/supervisor.cxx Fri Jul 25 01:00:20 2008
@@ -209,11 +209,10 @@
PString specialAnswer;
specialPacketHandler->ReportLists(specialAnswer);
- answer << "specialHand " << specialAnswer << "\n";
- {
- PWaitAndSignal m(mutexTokenTable);
- answer << "token size " << tokenTable.GetSize() << "\n";
- }
+ answer << "specialHand " << specialAnswer << "\n";
+ mutexTokenTable.StartRead();
+ answer << "token size " << tokenTable.GetSize() << "\n";
+ mutexTokenTable.EndRead();
{
PWaitAndSignal m(regProcessorsMutex);
answer << "Reg Processors " << regProcessors.GetSize() << "\n";
1
0
Author: derek
Date: Mon Jul 21 23:13:27 2008
New Revision: 431
Modified:
sofaswitch/trunk/am/audio.cxx
sofaswitch/trunk/am/comms.cxx
Log:
Tidy up operation so it operates correctly when just the write file is specified.
Improve reporting on the status command to accurate describe what is happening.
Modified: sofaswitch/trunk/am/audio.cxx
==============================================================================
--- sofaswitch/trunk/am/audio.cxx (original)
+++ sofaswitch/trunk/am/audio.cxx Mon Jul 21 23:13:27 2008
@@ -70,6 +70,7 @@
EnactFileChange();
if (!audioFile.IsOpen()) {
+ PTRACE(3, "AudioRead\tNo action - source file is not available");
doThisRead = false;
}
@@ -80,7 +81,7 @@
PTRACE(1, "Send end of file as we hav read the end of this file." << fileName);
comms->SendEndOfFile();
sentEndOfFile = true;
- PTRACE(4, "End of this file, currently at " << audioFile.GetPosition() <<
+ PTRACE(4, "AudioRead\tEnd of this file, currently at " << audioFile.GetPosition() <<
" index, of a total of " <<audioFile.GetDataLength() << " bytes");
}
}
@@ -91,10 +92,10 @@
if (audioFile.GetErrorCode() != PChannel::NoError) {
doThisRead = false;
if (!sentEndOfFile) {
- PTRACE(1, "Send end of file as we had an error in read, " << audioFile.GetErrorText());
+ PTRACE(1, "AudioRead\tSend end of file as we had an error in read, " << audioFile.GetErrorText());
comms->SendEndOfFile();
sentEndOfFile = true;
- PTRACE(3, "AudioRead\t failed with error text " << audioFile.GetErrorText());
+ PTRACE(3, "AudioRead\tfailed with error text " << audioFile.GetErrorText());
}
}
lastReadCount = audioFile.GetLastReadCount();
@@ -102,7 +103,7 @@
}
if (doThisRead) {
- PTRACE(3, dirString << "\tGrabbed " << lastReadCount << " bytes from the file " << fileName);
+ PTRACE(3, dirString << "AudioRead\tGrabbed " << lastReadCount << " bytes from the file " << fileName);
delayTime = data.GetSize()/16;
countPackets++;
socket->Write(data.GetPointer(), data.GetSize());
@@ -111,7 +112,7 @@
}
}
- PTRACE(3, "Delay " << delayTime << " ms after the read");
+ PTRACE(3, "AudioRead\tDelay " << delayTime << " ms after the read");
delay.Delay(delayTime);
}
@@ -164,15 +165,16 @@
EnactFileChange();
if (!audioFile.IsOpen()) {
+ PTRACE(3, "AudioWrite\tNo action - destination file is closed");
continue;
}
audioFile.Write(data.GetPointer(), lastReadCount);
countPackets++;
- if (audioFile.GetErrorCode() != PChannel::NoError) {
- PTRACE(3, "AudioWrite\t failed with error text " << audioFile.GetErrorText());
+ if (audioFile.GetErrorCode() == PChannel::NoError) {
+ PTRACE(3, "AudioWrite\tSent " << lastReadCount << " bytes to the file " << fileName);
} else {
- PTRACE(3, "AudioWrite\tSent " << data.GetSize() << " bytes to the file " << fileName);
+ PTRACE(3, "AudioWrite\t failed with error text " << audioFile.GetErrorText());
}
}
}
Modified: sofaswitch/trunk/am/comms.cxx
==============================================================================
--- sofaswitch/trunk/am/comms.cxx (original)
+++ sofaswitch/trunk/am/comms.cxx Mon Jul 21 23:13:27 2008
@@ -167,9 +167,12 @@
{
PTRACE(3, "Coms::ProcessStatusQuery");
- if (!audioReadThread.IsInitialised()) {
- SendThisMessageTo("not yet in a call", sender);
- return;
+ if ((!audioReadThread.IsInitialised()) && (!audioWriteThread.IsInitialised())) {
+ PStringStream answer;
+ answer << "\n Currently linked to " << GetMediaPartner();
+ answer << "\n No audio file specified - read and/or write cannot happen.\n";
+ SendThisMessageTo(answer, sender);
+ return;
}
PString status = GetStatusInfo();
1
0
Author: derek
Date: Sun Jul 20 22:45:12 2008
New Revision: 430
Modified:
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
sofaswitch/trunk/voip/supervisor.cxx
sofaswitch/trunk/voip/supervisor.h
Log:
Add additional command of (iaxstatus and iaxstatus full)
This command reports on the usage in OPAL's iax lists.
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 20 22:45:12 2008
@@ -330,7 +330,7 @@
// Create IAX2 protocol handler
if (!args.HasOption("no-iax2")) {
- iax2EP = new IAX2EndPoint(*this);
+ iax2EP = new ReportingIAX2EndPoint(*this);
if (args.HasOption('p'))
iax2EP->SetPassword(args.GetOptionString('p'));
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Sun Jul 20 22:45:12 2008
@@ -229,6 +229,16 @@
comms instances in a call */
PSortedStringList GetCurrentNames();
+
+ /**Return the pointer to the iax2 endpoint. This is used for
+ retrieving stats, and is dangerous to be used for other
+ things. */
+#if OPAL_IAX2
+ void *GetIax2Ep() { return (void *)iax2EP; }
+#else
+ void *GetIax2Ep() { return NULL; }
+#endif
+
protected:
/**The interface to the external script which runs python, to provide comms for us */
LaunchNewId &lid;
Modified: sofaswitch/trunk/voip/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/voip/supervisor.cxx (original)
+++ sofaswitch/trunk/voip/supervisor.cxx Sun Jul 20 22:45:12 2008
@@ -29,6 +29,7 @@
*/
#include <ptlib.h>
+#include <iax2/receiver.h>
#ifdef __GNUC__
#pragma implementation "supervisor.h"
@@ -42,6 +43,7 @@
#include "supervisor.h"
+
#define new PNEW
////////////////////////////////////////////////////////////////////////////////
@@ -52,6 +54,8 @@
{
IncSupervisor();
PTRACE(3, "Create a supervisor ");
+
+ extraAvailableCommands += PString(/* 0 */ "IAXSTATUS");
}
Supervisor::~Supervisor()
@@ -150,6 +154,74 @@
VoipProcess::Current().GetManager()->RequestNewId(sender);
}
+bool Supervisor::ProcessDescendantCommands(const PStringArray & cmds,
+ const PString & sender)
+{
+ if (extraAvailableCommands[0] *= cmds[0]) {
+ PTRACE(4, "Process iax status");
+ ProcessIaxStatus(cmds, sender);
+ return true;
+ }
+
+ return false;
+}
+
+void Supervisor::ProcessIaxStatus(const PStringArray & cmds,
+ const PString & sender)
+{
+ MyManager *opal = VoipProcess::Current().GetManager();
+ PStringStream answer;
+
+ void *iax2Ep = opal->GetIax2Ep();
+ if (iax2Ep == NULL) {
+ answer << PString("FAILED as this SofaSwitch node does ");
+ answer << PString("not support iax. Sorry");
+ }
+
+#if OPAL_IAX2
+ ReportingIAX2EndPoint *r = (ReportingIAX2EndPoint *)iax2Ep;
+ bool fullReport = false;
+ if (cmds.GetSize() >= 2) {
+ fullReport = cmds[1] *= PString("full");
+ }
+ answer << PString("\n") << r->GetListSizes(fullReport);
+#endif
+
+ SendThisMessageTo(answer, sender);
+ return;
+}
+/////////////////////////////////////////////////////////////////////////////
+
+ReportingIAX2EndPoint::ReportingIAX2EndPoint(OpalManager & manager)
+ : IAX2EndPoint(manager)
+{
+
+}
+
+PString ReportingIAX2EndPoint::GetListSizes(bool getFullReport)
+{
+ PStringStream answer;
+ PString transmitterAnswer;
+ ReportTransmitterLists(transmitterAnswer, getFullReport);
+ answer << "Transmitter " << transmitterAnswer;
+ answer << "Receiver " << receiver->GetSize() << "\n";
+ answer << "RegProcessor" << regProcessors.GetSize() << "\n";
+
+ PString specialAnswer;
+ specialPacketHandler->ReportLists(specialAnswer);
+ answer << "specialHand " << specialAnswer << "\n";
+ {
+ PWaitAndSignal m(mutexTokenTable);
+ answer << "token size " << tokenTable.GetSize() << "\n";
+ }
+ {
+ PWaitAndSignal m(regProcessorsMutex);
+ answer << "Reg Processors " << regProcessors.GetSize() << "\n";
+ }
+
+ return answer;
+}
+
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 2 spaces. */
Modified: sofaswitch/trunk/voip/supervisor.h
==============================================================================
--- sofaswitch/trunk/voip/supervisor.h (original)
+++ sofaswitch/trunk/voip/supervisor.h Sun Jul 20 22:45:12 2008
@@ -36,6 +36,7 @@
#include <ptlib.h>
#endif
+#include <iax2/iax2ep.h>
#include <sofa/messages.h>
#ifdef P_USE_PRAGMA
@@ -62,6 +63,17 @@
things like memory leak checkpoints */
virtual void OnRunning();
+ /**The voip supervisor can do extra commands that the generic message handler
+ cannot process. This method catches these extra command handling.
+
+ @return true if the voip supervisor did manage to decode the
+ commands. The default return is false; */
+ virtual bool ProcessDescendantCommands(const PStringArray & /*cmds*/,
+ const PString & /*sender*/);
+
+ /**Report here the extra commands the voip supervisor can process */
+ virtual PStringArray GetDescendantCommands() { return extraAvailableCommands; }
+
protected:
/**The supervisor has completed. This method is called when this
supervisor instance terminates. Since there is only one
@@ -100,6 +112,9 @@
/**Placed here - the child class has this method as pure virtual... */
virtual void ProcessAnswer(PStringArray &cmds, PString & sender);
+ /**Report to the sender the status of the lists in the iax portion of opal. */
+ virtual void ProcessIaxStatus(const PStringArray &cmds, const PString & sender);
+
/**Some MessageFrame instances do not have the permission to quit
now. This virtual method determines if this instance is permitted to
exit the program. This is the supervisor, so we can cause a shutdown. */
@@ -109,6 +124,8 @@
no message to the remote node - just end end end. */
virtual void SilentlyEndAll();
+ /**The list of extra commands we can handle in the voip supervisor */
+ PStringArray extraAvailableCommands;
//////////////////////////////////////////////
private:
@@ -120,6 +137,25 @@
// CommsProvider availableComms;
};
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/**the purpose of this class is to access the members of the iax2ep for reporting on size */
+
+class ReportingIAX2EndPoint : public IAX2EndPoint
+{
+ PCLASSINFO(ReportingIAX2EndPoint, IAX2EndPoint);
+
+ public:
+ /**constructor, which just calls the descendant */
+ ReportingIAX2EndPoint(OpalManager & manager);
+
+ /**Get a string which details the size of the internal lists */
+ PString GetListSizes(bool getFullReport = false);
+};
+
+
+
#endif // _SUPERVISOR_H
1
0
Author: derek
Date: Sun Jul 20 22:43:21 2008
New Revision: 429
Modified:
sofaswitch/trunk/server/main.h
Log:
Tidy up formatting of doxygen comment.
Modified: sofaswitch/trunk/server/main.h
==============================================================================
--- sofaswitch/trunk/server/main.h (original)
+++ sofaswitch/trunk/server/main.h Sun Jul 20 22:43:21 2008
@@ -365,8 +365,9 @@
} connectionsActive;
#ifdef DOC_PLUS_PLUS
- /**This does the work of deleting all active connections. Using a thread to do the work
- saves a deadlock from an active connection trying to enact a close down. */
+ /**This does the work of deleting all active connections. Using a
+ thread to do the work saves a deadlock from an active connection
+ trying to enact a close down. */
virtual void DoQuitNow(PThread &, INT);
#else
PDECLARE_NOTIFIER(PThread, Manager, DoQuitNow);
1
0