[Sofaswitch-svn] [commit] r242 - sofaswitch/trunk/voip
Author: derek Date: Tue Feb 13 23:11:32 2007 New Revision: 242 Modified: sofaswitch/trunk/voip/jocall.cxx sofaswitch/trunk/voip/mymanager.cxx sofaswitch/trunk/voip/mymanager.h sofaswitch/trunk/voip/udpconnection.cxx sofaswitch/trunk/voip/udpconnection.h sofaswitch/trunk/voip/udpep.cxx sofaswitch/trunk/voip/udpep.h Log: Add code to cope with recent changes in the openh323 cvs, which creates the variable stringOptions. Currently, this variable is Not set to null, so calls crash (which use h323/sip) Modified: sofaswitch/trunk/voip/jocall.cxx ============================================================================== --- sofaswitch/trunk/voip/jocall.cxx (original) +++ sofaswitch/trunk/voip/jocall.cxx Tue Feb 13 23:11:32 2007 @@ -107,7 +107,7 @@ 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) { Modified: sofaswitch/trunk/voip/mymanager.cxx ============================================================================== --- sofaswitch/trunk/voip/mymanager.cxx (original) +++ sofaswitch/trunk/voip/mymanager.cxx Tue Feb 13 23:11:32 2007 @@ -822,7 +822,7 @@ call->SetPartyB(partyB); - if (MakeConnection(*call, partyA)) + if (MakeConnection(*call, partyA, NULL)) return TRUE; call->Clear(); @@ -896,9 +896,22 @@ BOOL MyManager::OnIncomingConnection(OpalConnection & connection) { + return OnIncomingConnection(connection, 0); +} + +BOOL MyManager::OnIncomingConnection(OpalConnection & connection, + unsigned options) +{ + return OnIncomingConnection(connection, options, NULL); +} + +BOOL MyManager::OnIncomingConnection(OpalConnection & connection, + unsigned options, + OpalConnection::StringOptions *stringOptions) +{ PTRACE(3, "Incoming connection from " << connection.GetRemotePartyName()); - return OpalManager::OnIncomingConnection(connection); + return OpalManager::OnIncomingConnection(connection, options, stringOptions); } OpalConnection::AnswerCallResponse Modified: sofaswitch/trunk/voip/mymanager.h ============================================================================== --- sofaswitch/trunk/voip/mymanager.h (original) +++ sofaswitch/trunk/voip/mymanager.h Tue Feb 13 23:11:32 2007 @@ -39,6 +39,7 @@ #include <ptlib.h> #include <ptclib/ipacl.h> #include <opal/manager.h> +#include <opal/connection.h> #include "comms.h" @@ -75,22 +76,63 @@ /**Where we sit, while waiting for commands & events */ void Main(PArgList & args); - /**Call back for answering an incoming call. + /**Call back for answering an incoming call. + This function is used for an application to control the answering of + incoming calls. + + If TRUE is returned then the connection continues. If FALSE then the + connection is aborted. + + Note this function should not block for any length of time. If the + decision to answer the call may take some time eg waiting for a user to + pick up the phone, then AnswerCallPending or AnswerCallDeferred should + be returned. + + If an application overrides this function, it should generally call the + ancestor version to complete calls. Unless the application completely + takes over that responsibility. Generally, an application would only + intercept this function if it wishes to do some form of logging. For + this you can obtain the name of the caller by using the function + OpalConnection::GetRemotePartyName(). + + The default behaviour is to call OnRouteConnection to determine a + B party for the connection. + + If the call associated with the incoming call already had two parties + and this connection is a third party for a conference call then + AnswerCallNow is returned as a B party is not required. + */ + virtual BOOL OnIncomingConnection( + OpalConnection & connection, ///< Connection that is calling + unsigned options, ///< options for new connection (can't use default as overrides will fail) + OpalConnection::StringOptions * stringOptions///< Used for specifiy local party name etc. NULL is a valid value. + ); + + /**Call back for answering an incoming call, identical to above + This function is used for an application to control the answering of + incoming calls. + */ + virtual BOOL OnIncomingConnection( + OpalConnection & connection, ///< Connection that is calling + unsigned options ///< options for new connection (can't use default as overrides will fail) + ); + + /**Call back for answering an incoming call, identical to above This function is used for an application to control the answering of incoming calls. */ virtual BOOL OnIncomingConnection( - OpalConnection & connection /// Connection that is calling + OpalConnection & connection ///< Connection that is calling ); /**A call has been established, and now is running with media in both directions */ virtual void OnEstablishedCall( - OpalCall & call /// Call that was completed + OpalCall & call ///< Call that was completed ); /**A call has been cleared, and is about to be totally destroyed */ virtual void OnClearedCall( - OpalCall & call /// Connection that was established + OpalCall & call ///< Connection that was established ); /**Create a new media stream for them to use */ Modified: sofaswitch/trunk/voip/udpconnection.cxx ============================================================================== --- sofaswitch/trunk/voip/udpconnection.cxx (original) +++ sofaswitch/trunk/voip/udpconnection.cxx Tue Feb 13 23:11:32 2007 @@ -65,15 +65,17 @@ OpalUdpSsConnection::OpalUdpSsConnection(OpalCall & call, OpalUdpSsEndPoint & ep, - const PString & newToken) - : OpalConnection(call, ep, newToken), + const PString & newToken, + unsigned int options, + OpalConnection::StringOptions * _stringOptions) + : OpalConnection(call, ep, newToken, options, _stringOptions), endpoint(ep) { IncOpalUdpSsConnection(); silenceDetector = new OpalPCM16SilenceDetector; - PTRACE(3, "UdpSs\tCreated UDP sound system OpalConnection" << GetToken()); + PTRACE(3, "UdpSs\tCreated UDP sound system OpalUdpSsConnection" << GetToken()); } @@ -93,18 +95,47 @@ BOOL OpalUdpSsConnection::SetUpConnection() { - PTRACE(3, "SETUPConnection "); - remotePartyName = ownerCall.GetOtherPartyConnection(*this)->GetRemotePartyName(); remotePartyAddress = ownerCall.GetOtherPartyConnection(*this)->GetRemotePartyAddress(); remoteApplication = ownerCall.GetOtherPartyConnection(*this)->GetRemoteApplication(); - PTRACE(3, "UdpSs\tSetUpConnection(" << remotePartyName << ')'); - phase = AlertingPhase; - endpoint.OnShowIncoming(*this); - OnAlerting(); - + PTRACE(3, "UdpSs\tSetUpConnection, Remote party name " << remotePartyName << ')'); + PTRACE(3, "UdpSs\tSetUpConnection, Remote party address" << remotePartyAddress << ')'); + PTRACE(3, "UdpSs\tSetUpConnection, Remote application " << remoteApplication << ')'); + + // Check if we are A-Party in thsi call, so need to do things differently + if (ownerCall.GetConnection(0) == this) { + phase = SetUpPhase; + if (!OnIncomingConnection(0, NULL)) { + Release(EndedByCallerAbort); + return FALSE; + } + + PTRACE(2, "PCSS\tOutgoing call routed to " << ownerCall.GetPartyB() << " for " << *this); + if (!ownerCall.OnSetUp(*this)) { + Release(EndedByNoAccept); + return FALSE; + } + return TRUE; + } + + { + PSafePtr<OpalConnection> otherConn = ownerCall.GetOtherPartyConnection(*this); + if (otherConn == NULL) + return FALSE; + + remotePartyName = otherConn->GetRemotePartyName(); + remotePartyAddress = otherConn->GetRemotePartyAddress(); + remoteApplication = otherConn->GetRemoteApplication(); + } + + PTRACE(3, "PCSS\tSetUpConnection(" << remotePartyName << ')'); + phase = AlertingPhase; + endpoint.OnShowIncoming(*this); + OnAlerting(); + + return TRUE; } Modified: sofaswitch/trunk/voip/udpconnection.h ============================================================================== --- sofaswitch/trunk/voip/udpconnection.h (original) +++ sofaswitch/trunk/voip/udpconnection.h Tue Feb 13 23:11:32 2007 @@ -58,8 +58,10 @@ OpalUdpSsConnection( OpalCall & call, /*!< Owner calll for connection */ OpalUdpSsEndPoint & endpoint, /*!< Owner endpoint for connection */ - const PString & newToken /*!< token for this connection */ - ); + const PString & newToken, /*!< token for this connection */ + unsigned int options, + OpalConnection::StringOptions * _stringOptions); + /**Destroy endpoint. */ Modified: sofaswitch/trunk/voip/udpep.cxx ============================================================================== --- sofaswitch/trunk/voip/udpep.cxx (original) +++ sofaswitch/trunk/voip/udpep.cxx Tue Feb 13 23:11:32 2007 @@ -75,19 +75,9 @@ } BOOL OpalUdpSsEndPoint::MakeConnection(OpalCall & call, - const PString & remoteParty, + const PString & remoteParty, void * userData) { - return MakeConnection(call, remoteParty, userData, 0); -} - - - -BOOL OpalUdpSsEndPoint::MakeConnection(OpalCall & call, - const PString & remoteParty, - void * userData, - unsigned int /*options*/) -{ // First strip of the prefix if present PINDEX prefixLength = 0; if (remoteParty.Find(GetPrefixName()+":") == 0) @@ -95,12 +85,12 @@ const PString conToken = MakeToken(); - PSafePtr<OpalUdpSsConnection> connection = CreateConnection(call, userData, conToken); + PSafePtr<OpalUdpSsConnection> connection = CreateConnection(call, userData, conToken); if (connection == NULL) { PTRACE(1, "Failed to create a connection on " << conToken); return FALSE; } - + connectionsActive.SetAt(conToken, connection); // If we are the A-party then need to initiate a call now in this thread and @@ -113,6 +103,27 @@ return TRUE; } + + + +BOOL OpalUdpSsEndPoint::MakeConnection(OpalCall & call, + const PString & remoteParty, + void * userData, + unsigned int /*options*/, + OpalConnection::StringOptions *stringOptions) +{ + return MakeConnection(call, remoteParty, userData); +} + +BOOL OpalUdpSsEndPoint::MakeConnection(OpalCall & call, + const PString & remoteParty, + void *userData, + unsigned int /*options*/) +{ + return MakeConnection(call, remoteParty, userData); +} + + PString OpalUdpSsEndPoint::OnGetDestination(const OpalUdpSsConnection & /*connection*/) { PTRACE(1, "OnGetDestination " << destinationAddress); @@ -149,7 +160,7 @@ const PString & newToken) { PTRACE(1, "Create opalUdpSsConnection"); - return new OpalUdpSsConnection(call, *this, newToken); + return new OpalUdpSsConnection(call, *this, newToken, 0, NULL); } Modified: sofaswitch/trunk/voip/udpep.h ============================================================================== --- sofaswitch/trunk/voip/udpep.h (original) +++ sofaswitch/trunk/voip/udpep.h Tue Feb 13 23:11:32 2007 @@ -101,22 +101,28 @@ The default behaviour is pure. */ virtual BOOL MakeConnection( - OpalCall & call, ///< Owner of connection - const PString & party, ///< Remote party to call - void * userData = NULL, ///< Arbitrary data to pass to connection - unsigned int options = 0 ///< options to pass to conneciton + OpalCall & call, ///< Owner of connection + const PString & party, ///< Remote party to call + void * userData = NULL ///< Arbitrary data to pass to connection + ); + virtual BOOL MakeConnection( + OpalCall & call, ///< Owner of connection + const PString & party, ///< Remote party to call + void * userData, ///< Arbitrary data to pass to connection + unsigned int options ///< options to pass to conneciton ); - - /**This filler method is identical to that above, and is provided as a - convenience, when working against different library versions.*/ virtual BOOL MakeConnection( - OpalCall & call, ///< Owner of connection - const PString & party, ///< Remote party to call - void * userData = NULL ///< Arbitrary data to pass to connection + OpalCall & call, ///< Owner of connection + const PString & party, ///< Remote party to call + void * userData, ///< Arbitrary data to pass to connection + unsigned int options, ///< options to pass to conneciton + OpalConnection::StringOptions * stringOptions ); + + /**Get the data formats this endpoint is capable of operating. This provides a list of media data format names that may be used by an OpalMediaStream may be created by a connection from this endpoint.
participants (1)
-
SofaSWITCH SVN