📄 opincallfarendanswered.cxx
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 1999, 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 end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by Vovida Networks, * Inc. (http://www.vovida.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. 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. * * 5. 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 AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL VOVIDA NETWORKS, INC. OR ITS * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 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 OpInCallFarEndAnswered_cxx_Version = "$Id: OpInCallFarEndAnswered.cxx,v 1.26 2002/11/09 02:13:07 derekm Exp $";#include "global.h"#include "SipEvent.hxx"#include "AckMsg.hxx"#include "OpInCallFarEndAnswered.hxx"#include "OpFarEndAnswered.hxx"#include "UaStateMachine.hxx"#include "UaCallInfo.hxx"#include "SipTransceiver.hxx"#include "SipSdp.hxx"#include "SystemInfo.hxx"using namespace Vocal;OpInCallFarEndAnswered::OpInCallFarEndAnswered(){}OpInCallFarEndAnswered::~OpInCallFarEndAnswered(){}const char* constOpInCallFarEndAnswered::name() const{ return "OpInCallFarEndAnswered";}const Sptr < State >OpInCallFarEndAnswered::process( const Sptr < SipProxyEvent > event ){ cpLog( LOG_DEBUG, "OpInCallFarEndAnswered operation" ); Sptr < SipEvent > sipEvent; sipEvent.dynamicCast( event ); if ( sipEvent == 0 ) { return 0; } Sptr < SipMsg > sipMsg = sipEvent->getSipMsg(); assert( sipMsg != 0 ); Sptr < StatusMsg > msg; msg.dynamicCast( sipMsg ); if ( msg == 0 ) { return 0; } Sptr < UaCallInfo > call; call.dynamicCast( event->getCallInfo() ); assert( call != 0 ); if ( !(call->findContact( *msg ) == call->getContact()) ) { return 0; } call->getContact()->update( *msg); int status = msg->getStatusLine().getStatusCode(); if ( status == 200 || status >= 400 ) { // Needs to ack farend cpLog( LOG_DEBUG, "sending an Ack"); AckMsg ack( *msg ); sipEvent->getSipStack()->sendAsync( ack ); } if ( status != 200 ) { return 0; // Done } // check to see if this is contact1. this could happen if you did a // flash while in StateInCallTrying. in this case, OpInCallStopTrying // would be called and contact2 cancelled. // the current contact is always set to Sptr < Contact > contact = call->getContact(); assert( contact != 0 ); Sptr < InviteMsg > invite2 = call->getRing2Invite(); if ( invite2 == 0 ) { //if no invite message to the second call, just return //this scenario shoud not happen cpLog( LOG_ERR, "No invite message to the second call" ); return 0; } InviteMsg contactInviteMsg = contact->getInviteMsg(); // the following comparison statement is equavalent to // if ( *invite2 != contactInviteMsg ) // != operator is not used because it is not define. if ( !(*invite2 == contactInviteMsg) ) { //if the invite message to the second call does not correspond to //the current contact, just return; return 0; } // Pull out contactToUrl Sptr< BaseUrl > baseUrl = contactInviteMsg.getTo().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 > contactToUrl; contactToUrl.dynamicCast( baseUrl ); assert( contactToUrl != 0 ); // Pull out msgToUrl baseUrl = msg->getTo().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 > msgToUrl; msgToUrl.dynamicCast( baseUrl ); assert( msgToUrl != 0 ); // the following comparison statement is equavalent to // if ( *contactToUrl != *msgToUrl ) // != operator is not used because it is not define. if ( !(*contactToUrl == *msgToUrl) ) { // the 200 message is coming from our sole contact (call 1) // so, we need to return without entering StateIn2Calls return 0; } // otherwise, this is contact2 cpLog( LOG_DEBUG, "Far End Answered"); cpLog( LOG_DEBUG, "200 received from Contact2" ); // save the route call->setCallerRoute2List( msg->getrecordrouteList() ); int numContact = msg->getNumContact(); if ( numContact ) { SipContact contact = msg->getContact( numContact - 1 ); Sptr < SipRoute > route = new SipRoute; route->setUrl( contact.getUrl() ); call->addRoute2( route ); } // Get remote SDP from message Sptr<SipSdp> sdp; sdp.dynamicCast( sipMsg->getContentData(0) ); if ( sdp == 0 ) { cpLog( LOG_ERR, "No remote SDP in ACK" ); } else { call->setRemote2Sdp( new SipSdp( *sdp ) ); } Sptr < UaStateMachine > stateMachine; stateMachine.dynamicCast( event->getCallInfo()->getFeature() ); assert( stateMachine != 0 ); return stateMachine->findState( "StateIn2Calls" );}/* 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 + -