📄 opring.cxx
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const OpRing_cxx_Version = "$Id: OpRing.cxx,v 1.47 2002/11/09 02:13:07 derekm Exp $";#include "global.h"#include "SipEvent.hxx"#include "InviteMsg.hxx"#include "OpRing.hxx"#include "UaHardwareEvent.hxx"#include "UaCallInfo.hxx"#include "UaDevice.hxx"#include "UaStateMachine.hxx"#include "UaConfiguration.hxx"#include "SdpHandler.hxx"#include "RsvpHandler.hxx"#include "SystemInfo.hxx"#include "UaCommandLine.hxx" #include "SipVia.hxx"#ifndef NO_POLICY#include "PepAgent.hxx"#endifusing namespace Vocal;OpRing::OpRing(){}OpRing::~OpRing(){}const char* constOpRing::name() const{ return "OpRing";}const Sptr < State >OpRing::process( const Sptr < SipProxyEvent > event ){ cpLog( LOG_DEBUG, "OpRing operation" ); Sptr < SipEvent > sipEvent; sipEvent.dynamicCast( event ); if ( sipEvent == 0 ) { return 0; } Sptr < SipMsg > sipMsg = sipEvent->getSipMsg(); assert( sipMsg != 0 ); Sptr < InviteMsg > msg; msg.dynamicCast( sipMsg ); if ( msg == 0 ) { cpLog( LOG_DEBUG, "Not an INVITE" ); return 0; } Sptr < UaCallInfo > call; call.dynamicCast( event->getCallInfo() ); assert( call != 0 ); cpLog( LOG_DEBUG, "Ring" ); // Save INVITE call->setRingInvite( new InviteMsg( *msg ) ); call->setContactMsg(*msg); //save route info call->setCalleeRoute1List( msg->getrecordrouteList() ); int numContact = msg->getNumContact(); if ( numContact ) { SipContact contact = msg->getContact( numContact - 1 ); Sptr < SipRoute > route = new SipRoute; route->setUrl( contact.getUrl() ); cpLog( LOG_DEBUG, "Remote contact: %s", route->encode().logData() ); call->addRoute1( route ); } // do this only if configured for voicemail // Voice mail front end string reason; string comment; SipViaList viaList = msg->getViaList(); SipViaList::iterator iter = viaList.begin(); reason = "Unknown"; LocalScopeAllocator lo; while ( iter != viaList.end() ) { comment = ((*iter)->getComment()).getData(lo); if ( comment.find( "Vovida:" ) != string::npos ) { if ( comment.find( "No Answer" ) != string::npos ) { reason = "No Answer"; } else if ( comment.find( "Busy" ) == string::npos ) { reason = "Busy"; } } iter++; } Sptr < UaHardwareEvent > signal = new UaHardwareEvent( UaDevice::getDeviceQueue() ); signal->type = HardwareSignalType; signal->signalOrRequest.signal = DeviceSignalFwding; signal->dataList.push_back( reason ); Sptr< BaseUrl > baseUrl = msg->getFrom().getUrl(); assert( baseUrl != 0 ); if( baseUrl->getType() == TEL_URL ) { cpLog( LOG_ERR, "TEL_URL currently not supported\n" ); assert( 0 ); } // Assume we have a SIP_URL Sptr< SipUrl > sipUrl; sipUrl.dynamicCast( baseUrl ); assert( sipUrl != 0 ); Data callingNum = sipUrl->getUserValue(); //Merge: 2 lines from sip/uavm callingNum += "@"; callingNum += sipUrl->getHost(); signal->dataList.push_back( callingNum.getData(lo) ); SipRequestLine reqLine = msg->getRequestLine(); baseUrl = reqLine.getUrl(); assert( baseUrl != 0 ); if( baseUrl->getType() == TEL_URL ) { cpLog( LOG_ERR, "TEL_URL currently not supported\n" ); assert( 0 ); } // Assume we have a SIP_URL sipUrl.dynamicCast( baseUrl ); assert( sipUrl != 0 ); string calledNum = sipUrl->getUserValue().getData(lo); signal->dataList.push_back( calledNum ); UaDevice::getDeviceQueue()->add( signal ); Sptr<SipSdp> remoteSdp; remoteSdp.dynamicCast (msg->getContentData(0)); bool ringbackTone = false; //constructing local SDP SipSdp localSdp; if ( remoteSdp != 0 ) { localSdp = *remoteSdp; Data host = theSystem.gethostAddress(); if(UaConfiguration::instance()->getNATAddress() != "") { host = UaConfiguration::instance()->getNATAddress(); } setStandardSdp(localSdp, host, UaDevice::instance()->getRtpPort()); } // get the status of the hardware available or not available or // available for call waiting only HardwareStatusType hdwStatus = UaDevice::instance()->getHardwareStatus(); // for now support remote ringback only for the first call, not on // call waiting StatusMsg statusMsg; if (UaConfiguration::instance()->getProvideRingback() && hdwStatus == HARDWARE_AVAILABLE && (remoteSdp != 0) ) { ringbackTone = true; StatusMsg status( *msg, 183 ); status.setContentData( &localSdp ); call->setLocalSdp( new SipSdp( localSdp ) ); statusMsg = status; } else { // If ProvideRingback is off, then we send a 180 WITHOUT SDP StatusMsg status( *msg, 180 ); statusMsg = status; } if ( remoteSdp != 0 && UaConfiguration::instance()->getProvideRingback() ) { // do policy / rsvp stuff call->setRemoteSdp( new SipSdp( *remoteSdp ) ); call->setLocalSdp( new SipSdp( localSdp ) ); Sptr < SipSdp > localSdp = call->getLocalSdp(); Sptr < SipSdp > remoteSdp = call->getRemoteSdp();#ifndef NO_POLICY if (UaConfiguration::instance()->getUsePolicyServer() ) { cpLog(LOG_DEBUG,"Enable QoS handled in Marshal"); }#endif setupRsvp(*localSdp, *remoteSdp); } // TODO Call log Show caller information if ( !UaCommandLine::instance()->getBoolOpt( "voicemail" ) ) { cout << endl << VTime::strftime("%y/%m/%d %H:%M:%S") << " Call " << msg->getFrom().encode().logData() << endl; } else { cpLog(LOG_DEBUG, "Call:%s", msg->getFrom().encode().logData()); } Sptr < SipCallId > callId = new SipCallId( sipEvent->getSipCallLeg()->getCallId() ); if ( hdwStatus == HARDWARE_AVAILABLE ) { // Grab the device for this call UaDevice::instance()->setCallId( callId ); } else if ( hdwStatus == HARDWARE_CALLWAITING_ALLOWED ) { //set this call to be on call waiting UaDevice::instance()->addCallWaitingId( callId ); } else { //this case should not happen return 0; } sipEvent->getSipStack()->sendReply( statusMsg ); //turn on remote ringback if required if ( ringbackTone ) { sendRemoteRingback(*remoteSdp); } Sptr < UaStateMachine > stateMachine; stateMachine.dynamicCast( event->getCallInfo()->getFeature() ); assert( stateMachine != 0 ); return stateMachine->findState( "StateRinging" );}/* Local Variables: *//* c-file-style: "stroustrup" *//* indent-tabs-mode: nil *//* c-file-offsets: ((access-label . -) (inclass . ++)) *//* c-basic-offset: 4 *//* End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -