📄 uabase.hxx
字号:
#ifndef UaBase_hxx#define UaBase_hxx/* ==================================================================== * 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 UaBase_hxx_Version = "$Id: UaBase.hxx,v 1.7.2.5 2003/03/04 00:42:52 sprajpat Exp $";#include <string>#include <vector>#include "InviteMsg.hxx" #include "SipCallLegData.hxx" #include "SipProxyEvent.hxx" #include "SipTransceiver.hxx" #include "UaStateFactory.hxx" namespace Vocal {namespace UA {/** Object UaBase<pre> This should be called by the application to setup the proxy, sip-port and transport(1= UDP, 2=TCP)</pre>*/extern voidlibSipInit(NetworkAddress& proxyAddess, int sipPort, Data NATHOST=theSystem.gethostAddress(), int transport=1);class BasicAgent;/** Base class for Server/Client side User agents. The class maintains its* own local sequence for any request generated either as UAS or UAC.*/class UaBase : public SipCallLegData { public: typedef vector <SipRoute* > RouteList; /**Constructor * @param reqMsg - Message that causes its creation (UAS, msg received), (UAC, msg being sent). * @param stack - Ref. to sipstack being used to send/receive SIP msgs. * @param controllerAgent - Ref. to the call-controller agent, managing a call. */ UaBase( const Sptr<SipMsg>& reqMsg , Sptr<SipTransceiver> stack, BasicAgent* controllerAgent) : SipCallLegData(reqMsg), myStack(stack), myControllerAgent(controllerAgent) { myState = UaStateFactory::instance().getState(U_STATE_IDLE); myLocalCSeq = reqMsg->getCSeq(); }; /// UaBase( const UaBase& src ) : SipCallLegData(src), myStack(src.myStack), myControllerAgent(src.myControllerAgent) { myState = src.myState; myAgentRole = src.myAgentRole; assert(myControllerAgent); } /// virtual string className() =0; /// virtual ~UaBase(); /// const UaBase& operator =( const UaBase& src ) { if(this != &src) { copyObj(src); myState = src.myState; myAgentRole = src.myAgentRole; myControllerAgent = src.myControllerAgent; myStack = src.myStack; } return *this; } ///Set the ua-agent state void setState(UaState* state) { myState = state; }; /**Gets called by the application when a message is received on the * calleg, the agent is representing. */ virtual void receivedMsg(const Sptr<SipMsg>& sipMsg); /// virtual void sendMsg(const Sptr<SipMsg>& sipMsg); ///Returns true if was UAC when created virtual bool isAClient() const { return (myAgentRole == A_CLIENT); } ///Returns true if was UAS when created virtual bool isAServer() const { return (myAgentRole == A_SERVER); } /**Constructs a BYE message and sends it. * Derived classes define how to construct the BYE msg. */ virtual Sptr<SipMsg> sendBye() = 0; ///Create a status message for the received request. virtual void sendReplyForRequest(const Sptr<SipMsg>& sipMsg, int statusCode); ///Acknowledge a status virtual void ackStatus(const Sptr<SipMsg>& msg); ///Utility function to create an invite from an invite message static Sptr<InviteMsg> createInvite(const Sptr<InviteMsg>& invMsg, bool changeCallId = true); ///Constructs a re-invite message from a Invite, updates the CSEQ. Sptr<InviteMsg> createReInvite(const Sptr<InviteMsg>& invMsg); /**Keeps a copy of the route list received in a request/response. * if UAC, route list is saved from the 200 OK received and order * is reversed. if UAS, route list is saved from the INVITE received. */ void saveRouteList(const Sptr<SipMsg>& msg, bool reverse); /// RouteList getRouteList() const { return myRouteList; }; ///Initialize the local seq number void setLocalCSeq(SipCSeq seq) { myLocalCSeq = seq; }; /// const SipCSeq& getLocalCSeq() const { return myLocalCSeq; }; /// Sptr<SipTransceiver> getSipTransceiver() { return myStack; } /// static int mySipPort; /// static NetworkAddress myProxyAddress; /// static int myTransport; /// static Data myNAThost; protected: /// void clearRouteList(); /// BasicAgent* getControllerAgent() { return myControllerAgent; } /// void setRole(AgentRole role) { myAgentRole = role; }; /// UaState* myState; /// AgentRole myAgentRole; /// RouteList myRouteList; /// friend class UaStateInCall; /// friend class UaStateRinging; /// friend class UaStateFailure; /// friend class UasStateTrying; /// friend class UaStateEnd; /// friend class UacStateTrying; /// friend class UaStateRedirect; /// friend class UaStateInHold; /// Sptr<SipTransceiver> myStack; /// BasicAgent* myControllerAgent; /// SipCSeq myLocalCSeq;};}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -