Author: derek Date: Mon Aug 6 21:03:57 2007 New Revision: 393 Modified: sofaswitch/trunk/voip/jocall.cxx sofaswitch/trunk/voip/jocall.h sofaswitch/trunk/voip/mymanager.cxx sofaswitch/trunk/voip/supervisor.cxx sofaswitch/trunk/voip/supervisor.h sofaswitch/trunk/voip/udpconnection.cxx sofaswitch/trunk/voip/udpconnection.h Log: Get h323 voice calls to mirror back. We make a h.323 call to ourselves, which we then detect coming back to us... Good.. Modified: sofaswitch/trunk/voip/jocall.cxx ============================================================================== --- sofaswitch/trunk/voip/jocall.cxx (original) +++ sofaswitch/trunk/voip/jocall.cxx Mon Aug 6 21:03:57 2007 @@ -158,6 +158,11 @@ OpalCall::OnReleased(connection); } +void MyOpalCall::SendThisMessageTo(const PString & message, const PString & destination) +{ + comms.SendThisMessageTo(message, destination); +} + void MyOpalCall::OnCleared() { PTRACE(2, "on cleared of this call " << myToken); @@ -176,7 +181,13 @@ void MyOpalCall::IncomingCall(const PString &remoteNode) { PTRACE(3, "Jocal - incoming call to query the remote controller on "); +} + +void MyOpalCall::QueryAcceptIncomingCall(const PString & remoteController, const PString &remoteParty) +{ + PString message = PString("QueryAcceptIncoming ") + remoteParty; + SendThisMessageTo(message, remoteController); } void MyOpalCall::AcceptThisCall(BOOL doAccept) Modified: sofaswitch/trunk/voip/jocall.h ============================================================================== --- sofaswitch/trunk/voip/jocall.h (original) +++ sofaswitch/trunk/voip/jocall.h Mon Aug 6 21:03:57 2007 @@ -134,6 +134,11 @@ void SendThisDtmf(const PString & userInput ///DTMF to send ); + /**This OpalCall descendant is controlled by some remote controller. In + this method, this descendant can send a message to that remote + controller about something */ + void SendThisMessageTo(const PString & message, const PString & destination); + /**Make the OpalConnections in this call accept/reject this incoming call. This will move the status of the incoming call to connecting/releasing @@ -161,6 +166,10 @@ /**Report the ID (as used by sofaswitch) of this comms instance. */ PString GetOurId() { return comms.GetOurId(); } + /**Send a message to the remote controller about an incoming call - and ask + for permission to answer it */ + void QueryAcceptIncomingCall(const PString & remoteController, const PString &remoteParty); + protected: /**Link to our controll manager */ Modified: sofaswitch/trunk/voip/mymanager.cxx ============================================================================== --- sofaswitch/trunk/voip/mymanager.cxx (original) +++ sofaswitch/trunk/voip/mymanager.cxx Mon Aug 6 21:03:57 2007 @@ -75,6 +75,7 @@ #include "mymanager.h" #include "supervisor.h" #include "udpep.h" +#include "udpconnection.h" #define new PNEW /////////////////////////////////////////////////////////////// @@ -443,11 +444,19 @@ OpalConnection::StringOptions * stringOptions ) { + PTRACE(3, "Manager\tOnIncomingConnection from " << connection); + if (connection.GetRemotePartyName().Find("udp Sound") != P_MAX_INDEX) return OpalManager::OnIncomingConnection(connection, options, stringOptions); - PString message = PString("QueryAcceptIncoming ") + connection.GetRemotePartyName(); - supervisor.SendThisMessageTo(message, GetControllerId()); + /*We, the manager, have an incoming call. It has to be queried back to the + remote controller, from the node handling the call itself. We do not want + to be responsible for handling setup/teardown of each call The remote + controller will send the answer to the newly created connection, who will + answer it. It is none of the supervisor's business the managing of answer + call yes/no. */ + + ((MyOpalCall &)connection.GetCall()).QueryAcceptIncomingCall(GetControllerId(), connection.GetRemotePartyName()); return OpalManager::OnIncomingConnection(connection, options, stringOptions); } Modified: sofaswitch/trunk/voip/supervisor.cxx ============================================================================== --- sofaswitch/trunk/voip/supervisor.cxx (original) +++ sofaswitch/trunk/voip/supervisor.cxx Mon Aug 6 21:03:57 2007 @@ -67,6 +67,16 @@ PTRACE(3, "Supervisor thread has ended"); } +void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender) +{ + PAssertAlways("Supervisor should not attempt to answer a call"); +} + +void Supervisor::ProcessTransferUdp(PStringArray &cmds, PString & sender) +{ + PAssertAlways("Supervisor should not attempt to transfer a call"); +} + void Supervisor::ProcessCallNode(PStringArray & cmds, PString & sender) { PTRACE(3, "Supervisor:: we can start a call to " << sender); @@ -115,7 +125,7 @@ void Supervisor::ProcessHangup(PStringArray &cmds, PString & sender) { - SendThisMessageTo(cmds[0] + PString(" is not handled by the supervisor - send it to the relevant call "), sender); + PAssertAlways("Supervisor should not process a Hangup message"); } Modified: sofaswitch/trunk/voip/supervisor.h ============================================================================== --- sofaswitch/trunk/voip/supervisor.h (original) +++ sofaswitch/trunk/voip/supervisor.h Mon Aug 6 21:03:57 2007 @@ -70,6 +70,10 @@ /**we have received a Call other Node command, so do it and reply accordingly*/ virtual void ProcessCallNode(PStringArray & cmds, PString & sender); + /**This method is overridden as an error handler. The supervisor should never + receive this message */ + void ProcessTransferUdp(PStringArray &cmds, PString & sender); + /**we have received a query status command, so do it and reply accordingly*/ virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); @@ -90,7 +94,7 @@ virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender); /**Placed here - the child class has this method as pure virtual... */ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender) { } + virtual void ProcessAnswer(PStringArray &cmds, 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/voip/udpconnection.cxx ============================================================================== --- sofaswitch/trunk/voip/udpconnection.cxx (original) +++ sofaswitch/trunk/voip/udpconnection.cxx Mon Aug 6 21:03:57 2007 @@ -223,6 +223,23 @@ OpalConnection::Release(reason); } +void OpalUdpSsConnection::SendThisMessageTo(const PString & message, const PString & destination) +{ + ((MyOpalCall &)GetCall()).SendThisMessageTo(message, destination); +} + +void OpalUdpSsConnection::QueryAcceptIncomingCall(const PString & destination) +{ + PSafePtr<OpalConnection> otherConn = ownerCall.GetOtherPartyConnection(*this); + if (otherConn == NULL) { + PTRACE(3, "SETUP\t Cannot query on accept incoming call. Probably because we are making a call."); + return; + } + + PString message = PString("QueryAcceptIncoming ") + otherConn->GetRemotePartyName(); + + ((MyOpalCall &)GetCall()).SendThisMessageTo(message, destination); +} PSoundChannel * OpalUdpSsConnection::CreateSoundChannel(BOOL isSource) { Modified: sofaswitch/trunk/voip/udpconnection.h ============================================================================== --- sofaswitch/trunk/voip/udpconnection.h (original) +++ sofaswitch/trunk/voip/udpconnection.h Mon Aug 6 21:03:57 2007 @@ -194,6 +194,15 @@ CallEndReason reason = EndedByLocalUser ///< Reason for call release ); + /**This connection is controlled by some remote controller. This + connection has to send a message to that remote controller about + something */ + void SendThisMessageTo(const PString & message, const PString & destination); + + /**There is an incoming call, which has created this udp connection. The incoming + call is coming in on a sip/iax2/h.323 connection. We have to send a message to the + remote controller, which is done through the MyOpalCall structure */ + void QueryAcceptIncomingCall(const PString & destination); //@}