1 /* 2 * Copyright (C) 2010-2011 Raphael Coeffic 3 * 4 * This file is part of SEMS, a free SIP media server. 5 * 6 * SEMS is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. This program is released under 10 * the GPL with the additional exemption that compiling, linking, 11 * and/or using OpenSSL is allowed. 12 * 13 * For a license to use the SEMS software under conditions 14 * other than those described here, or to purchase support for this 15 * software, please contact iptel.org by e-mail at the following addresses: 16 * info@iptel.org 17 * 18 * SEMS is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 */ 27 /** @file AmOfferAnswer.h */ 28 #ifndef AmOfferAnswer_h 29 #define AmOfferAnswer_h 30 31 #include "AmSdp.h" 32 #include "AmSipMsg.h" 33 34 class AmSipDialog; 35 36 class AmOfferAnswer 37 { 38 public: 39 enum OAState { 40 OA_None=0, 41 OA_OfferRecved, 42 OA_OfferSent, 43 OA_Completed, 44 __max_OA 45 }; 46 47 private: 48 OAState state; 49 OAState saved_state; 50 unsigned int cseq; 51 AmSdp sdp_remote; 52 AmSdp sdp_local; 53 54 AmSipDialog* dlg; 55 56 /** State maintenance */ 57 void saveState(); 58 int checkStateChange(); 59 60 /** SDP handling */ 61 int onRxSdp(unsigned int m_cseq, const AmMimeBody& body, const char** err_txt); 62 int onTxSdp(unsigned int m_cseq, const AmMimeBody& body); 63 int getSdpBody(string& sdp_body); 64 65 public: 66 /** Constructor */ 67 AmOfferAnswer(AmSipDialog* dlg); 68 69 /** Accessors */ 70 OAState getState(); 71 void setState(OAState n_st); 72 const AmSdp& getLocalSdp(); 73 const AmSdp& getRemoteSdp(); 74 75 void clear(); 76 void clearTransitionalState(); 77 78 /** Event handlers */ 79 int onRequestIn(const AmSipRequest& req); 80 int onReplyIn(const AmSipReply& reply); 81 int onRequestOut(AmSipRequest& req); 82 int onReplyOut(AmSipReply& reply); 83 int onRequestSent(const AmSipRequest& req); 84 int onReplySent(const AmSipReply& reply); 85 void onNoAck(unsigned int ack_cseq); 86 }; 87 88 #endif 89