/[resiprocate]/main/sip/resiprocate/dum/InviteSession.hxx
ViewVC logotype

Contents of /main/sip/resiprocate/dum/InviteSession.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3493 - (show annotations) (download)
Fri Nov 19 19:43:26 2004 UTC (15 years, 2 months ago) by sgodin
File size: 7427 byte(s)
-safety checks for existance of Event header. 
- make session timer helper methods private
1 #if !defined(RESIP_INVITESESSION_HXX)
2 #define RESIP_INVITESESSION_HXX
3
4 #include "resiprocate/dum/DialogUsage.hxx"
5 #include "resiprocate/SipMessage.hxx"
6 #include "resiprocate/dum/RefCountedDestroyer.hxx"
7
8 #include <map>
9
10 namespace resip
11 {
12
13 class SdpContents;
14
15 class InviteSession : public DialogUsage
16 {
17 public:
18
19 virtual void send(SipMessage& msg);
20
21 //call after setOffer. Will do the right thing w/ respect to an ACK to a
22 //200, eventually PRACK/UPDATE
23 virtual void send();
24
25 /// Called to set the offer that will be used in the next messages that
26 /// sends and offer. Does not send an offer
27 virtual void setOffer(const SdpContents* offer);
28
29 /// Called to set the answer that will be used in the next messages that
30 /// sends an offer. Does not send an answer
31 virtual void setAnswer(const SdpContents* answer);
32
33 /// Makes the dialog end. Depending on the current state, this might
34 /// results in BYE or CANCEL being sent.
35 virtual void end();
36
37 /// Rejects an offer at the SIP level. So this can send a 487 !dcm! --
38 /// should be 488? to a reinvite INVITE or an UPDATE
39 virtual SipMessage& rejectDialogModification(int statusCode);
40
41 //accept a re-invite, etc. Always 200?
42 virtual SipMessage& acceptDialogModification(int statusCode = 200);
43
44
45 // If the app has called setOffer prior to targetRefresh, the reINVITE
46 // will contain the proposed offer. If the peer supports UPDATE, always
47 // prefer UPDATE over reINVITE (no 3-way handshake required)
48 // !jf! there are more things you could update in the targetRefresh
49 //!dcm! -- the UPDATE rfc states that re-invite should be preferred on
50 // established dialogs, in case user approval is required.
51 virtual SipMessage& targetRefresh(const NameAddr& localUri);
52
53 //always does re-invite for now...ACK is hidden
54 //call setOffer or setAnswer bfore calling these.
55 //calling answerModifySession /wout setAnswer is invalid
56 virtual SipMessage& modifySession();
57
58 virtual SipMessage& makeRefer(const NameAddr& referTo);
59 virtual SipMessage& makeRefer(const NameAddr& referTo, InviteSessionHandle sessionToReplace);
60
61 const SdpContents* getLocalSdp() const;
62 const SdpContents* getRemoteSdp() const;
63
64 virtual SipMessage& makeInfo(auto_ptr<Contents> contents);
65
66 public:
67 virtual void dispatch(const SipMessage& msg);
68 virtual void dispatch(const DumTimeout& timer);
69
70 // typedef Handle<InviteSession> InviteSessionHandle;
71 InviteSessionHandle getSessionHandle();
72
73 typedef enum
74 {
75 None, // means no Offer or Answer (may have SDP)
76 Offer,
77 Answer
78 } OfferAnswerType;
79
80 protected:
81 typedef enum
82 {
83 Nothing,
84 Offerred,
85 Answered, // agreed
86 CounterOfferred
87 } OfferState;
88
89 // If sdp==0, the offer was rejected
90 void incomingSdp(const SipMessage& msg, const SdpContents* sdp);
91
92 // If sdp==0, the offer is being rejected
93 void sendSdp(SdpContents* sdp);
94
95 std::pair<OfferAnswerType, const SdpContents*> getOfferOrAnswer(const SipMessage& msg) const;
96
97 typedef enum
98 {
99 Initial, // No session setup yet
100 Early,
101 Proceeding,
102 Cancelled,
103 Connected,
104 Terminated,
105 ReInviting,
106 } State;
107
108 State mState;
109
110 typedef enum
111 {
112 NitComplete,
113 NitProceeding
114 } NitState;
115
116 NitState mNitState;
117
118 void handleSessionTimerResponse(const SipMessage& msg);
119 void handleSessionTimerRequest(const SipMessage& request, SipMessage &response);
120
121 InviteSession(DialogUsageManager& dum, Dialog& dialog, State initialState);
122 SipMessage& makeAck();
123 SipMessage& makeFinalResponse(int code);
124
125 OfferState mOfferState;
126 SdpContents* mCurrentLocalSdp;
127 SdpContents* mCurrentRemoteSdp;
128 SdpContents* mProposedLocalSdp;
129 SdpContents* mProposedRemoteSdp;
130 SdpContents* mNextOfferOrAnswerSdp;
131
132 SipMessage mLastRequest;
133 SipMessage mLastIncomingRequest;
134 SipMessage mLastResponse;
135 SipMessage mLastNit;
136
137 typedef map<int, SipMessage> CSeqToMessageMap;
138 CSeqToMessageMap mAckMap;
139 CSeqToMessageMap mFinalResponseMap;
140
141 bool mUserConnected;
142 SipMessage* mQueuedBye;
143
144 // Session Timer settings
145 int mSessionInterval;
146 bool mSessionRefresherUAS;
147 int mSessionTimerSeq;
148
149 virtual ~InviteSession();
150
151 typedef RefCountedDestroyer<InviteSession> Destroyer;
152 Destroyer mDestroyer;
153 friend class Destroyer::Guard;
154
155 private:
156 friend class Dialog;
157 friend class DialogUsageManager;
158
159 unsigned long mCurrentRetransmit200;
160
161 // disabled
162 InviteSession(const InviteSession&);
163 InviteSession& operator=(const InviteSession&);
164 };
165
166 }
167
168 #endif
169
170 /* ====================================================================
171 * The Vovida Software License, Version 1.0
172 *
173 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
174 *
175 * Redistribution and use in source and binary forms, with or without
176 * modification, are permitted provided that the following conditions
177 * are met:
178 *
179 * 1. Redistributions of source code must retain the above copyright
180 * notice, this list of conditions and the following disclaimer.
181 *
182 * 2. Redistributions in binary form must reproduce the above copyright
183 * notice, this list of conditions and the following disclaimer in
184 * the documentation and/or other materials provided with the
185 * distribution.
186 *
187 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
188 * and "Vovida Open Communication Application Library (VOCAL)" must
189 * not be used to endorse or promote products derived from this
190 * software without prior written permission. For written
191 * permission, please contact vocal@vovida.org.
192 *
193 * 4. Products derived from this software may not be called "VOCAL", nor
194 * may "VOCAL" appear in their name, without prior written
195 * permission of Vovida Networks, Inc.
196 *
197 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
198 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
200 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
201 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
202 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
203 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
204 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
205 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
206 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
207 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
208 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
209 * DAMAGE.
210 *
211 * ====================================================================
212 *
213 * This software consists of voluntary contributions made by Vovida
214 * Networks, Inc. and many individuals on behalf of Vovida Networks,
215 * Inc. For more information on Vovida Networks, Inc., please see
216 * <http://www.vovida.org/>.
217 *
218 */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27