/[resiprocate]/main/resip/dum/InviteSession.cxx
ViewVC logotype

Annotation of /main/resip/dum/InviteSession.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2846 - (hide annotations) (download)
Sun May 30 01:57:26 2004 UTC (15 years, 6 months ago) by jason
Original Path: main/sip/resiprocate/dum/InviteSession.cxx
File size: 8124 byte(s)
progress on client invite



1 jason 2725 #include "resiprocate/SipMessage.hxx"
2 jason 2846 #include "resiprocate/SdpContents.hxx"
3 jason 2725 #include "resiprocate/dum/Dialog.hxx"
4     #include "resiprocate/dum/DialogUsageManager.hxx"
5     #include "resiprocate/dum/InviteSession.hxx"
6 jason 2846 #include "resiprocate/dum/InviteSessionHandler.hxx"
7 jason 2555
8 jason 2846
9 davidb 2603 using namespace resip;
10    
11 jason 2809 InviteSession::InviteSession(DialogUsageManager& dum, Dialog& dialog)
12 davidb 2603 : BaseUsage(dum, dialog),
13 jason 2846 mOfferState(Nothing),
14 jason 2725 mCurrentLocalSdp(0),
15     mCurrentRemoteSdp(0),
16     mProposedLocalSdp(0),
17 jason 2809 mProposedRemoteSdp(0)
18 jason 2555 {
19 jason 2846 assert(mDum.mInviteSessionHandler);
20 jason 2555 }
21    
22 jason 2846
23 jason 2555 const SdpContents*
24     InviteSession::getLocalSdp()
25     {
26 jason 2725 return mCurrentLocalSdp;
27 jason 2555 }
28    
29     const SdpContents*
30     InviteSession::getRemoteSdp()
31     {
32 jason 2725 return mCurrentRemoteSdp;
33 jason 2555 }
34 davidb 2575
35 jason 2809 SipMessage&
36 jason 2621 InviteSession::end()
37     {
38 jason 2809 //assert(mState == Connected);
39 jason 2621
40 jason 2809 #if 0
41 jason 2621 // no way for the application to modify the BYE yet
42     SipMessage bye;
43     mDialog.makeBye(bye);
44     copyAuthorizations(bye);
45 jason 2809 //mDum.send(bye);
46     #endif
47     return mLastRequest;
48 jason 2621 }
49    
50 jason 2809 // If sdp==0, it means the last offer failed
51 jason 2846 void
52     InviteSession::incomingSdp(const SipMessage& msg, const SdpContents* sdp)
53 jason 2809 {
54     switch (mOfferState)
55     {
56 jason 2846 case Nothing:
57 jason 2809 assert(mCurrentLocalSdp == 0);
58     assert(mCurrentRemoteSdp == 0);
59 jason 2846 mProposedRemoteSdp = static_cast<SdpContents*>(sdp->clone());
60 jason 2809 mOfferState = Offerred;
61 jason 2846 mDum.mInviteSessionHandler->onOffer(getSessionHandle(), msg, sdp);
62 jason 2809 break;
63    
64     case Offerred:
65     mCurrentLocalSdp = mProposedLocalSdp;
66 jason 2846 mCurrentRemoteSdp = static_cast<SdpContents*>(sdp->clone());
67 jason 2809 mProposedLocalSdp = 0;
68     mProposedRemoteSdp = 0;
69     mOfferState = Answered;
70 jason 2846 mDum.mInviteSessionHandler->onAnswer(getSessionHandle(), msg, sdp);
71 jason 2809 break;
72    
73     case Answered:
74     assert(mProposedLocalSdp == 0);
75     assert(mProposedRemoteSdp == 0);
76 jason 2846 mProposedRemoteSdp = static_cast<SdpContents*>(sdp->clone());
77 jason 2809 mOfferState = CounterOfferred;
78 jason 2846 mDum.mInviteSessionHandler->onOffer(getSessionHandle(), msg, sdp);
79 jason 2809 break;
80    
81    
82     case CounterOfferred:
83     assert(mCurrentLocalSdp);
84     assert(mCurrentRemoteSdp);
85 jason 2846 mOfferState = Answered;
86 jason 2809 if (sdp)
87     {
88     mCurrentLocalSdp = mProposedLocalSdp;
89 jason 2846 mCurrentRemoteSdp = static_cast<SdpContents*>(sdp->clone());
90     mDum.mInviteSessionHandler->onAnswer(getSessionHandle(), msg, sdp);
91 jason 2809 }
92     else
93     {
94     mProposedLocalSdp = 0;
95     mProposedRemoteSdp = 0;
96 jason 2846 // !jf! is this right?
97     mDum.mInviteSessionHandler->onOfferRejected(getSessionHandle(), msg);
98 jason 2809 }
99     break;
100     }
101     }
102    
103 jason 2621 void
104 jason 2846 InviteSession::sendSdp(const SdpContents* sdp)
105 jason 2809 {
106     switch (mOfferState)
107     {
108 jason 2846 case Nothing:
109 jason 2809 assert(mCurrentLocalSdp == 0);
110     assert(mCurrentRemoteSdp == 0);
111 jason 2846 mProposedLocalSdp = static_cast<SdpContents*>(sdp->clone());
112 jason 2809 mOfferState = Offerred;
113     break;
114    
115     case Offerred:
116 jason 2846 mCurrentLocalSdp = static_cast<SdpContents*>(sdp->clone());
117 jason 2809 mCurrentRemoteSdp = mProposedRemoteSdp;
118     mProposedLocalSdp = 0;
119     mProposedRemoteSdp = 0;
120     mOfferState = Answered;
121     break;
122    
123     case Answered:
124     assert(mProposedLocalSdp == 0);
125     assert(mProposedRemoteSdp == 0);
126 jason 2846 mProposedLocalSdp = static_cast<SdpContents*>(sdp->clone());
127 jason 2809 mOfferState = CounterOfferred;
128     break;
129    
130    
131     case CounterOfferred:
132     assert(mCurrentLocalSdp);
133     assert(mCurrentRemoteSdp);
134     if (sdp)
135     {
136 jason 2846 mCurrentLocalSdp = static_cast<SdpContents*>(sdp->clone());
137 jason 2809 mCurrentRemoteSdp = mProposedRemoteSdp;
138     }
139     else
140     {
141     mProposedLocalSdp = 0;
142     mProposedRemoteSdp = 0;
143     }
144     mOfferState = Answered;
145     break;
146     }
147     }
148    
149 jason 2846 std::pair<InviteSession::OfferAnswerType, const SdpContents*>
150     InviteSession::getOfferOrAnswer(const SipMessage& msg) const
151     {
152     std::pair<InviteSession::OfferAnswerType, const SdpContents*> ret;
153     ret.first = None;
154    
155     const SdpContents* contents = dynamic_cast<const SdpContents*>(msg.getContents());
156     if (contents)
157     {
158     static Token c100rel(Symbols::C100rel);
159     if (msg.isRequest() ||
160     msg.exists(h_Supporteds) && msg.header(h_Supporteds).find(c100rel))
161     {
162     switch (mOfferState)
163     {
164     case None:
165     ret.first = Offer;
166     ret.second = contents;
167     break;
168    
169     case Offerred:
170     ret.first = Answer;
171     ret.second = contents;
172     break;
173    
174     case Answered:
175     ret.first = Offer;
176     ret.second = contents;
177     break;
178    
179     case CounterOfferred:
180     ret.first = Answer;
181     ret.second = contents;
182     break;
183     }
184     }
185     }
186     return ret;
187     }
188    
189    
190 jason 2809 void
191 jason 2621 InviteSession::copyAuthorizations(SipMessage& request)
192     {
193 jason 2725 #if 0
194 jason 2621 if (mLastRequest.exists(h_ProxyAuthorizations))
195     {
196     // should make the next auth (change nextNonce)
197     request.header(h_ProxyAuthorizations) = mLastRequest.header(h_ProxyAuthorizations);
198     }
199     if (mLastRequest.exists(h_ProxyAuthorizations))
200     {
201     // should make the next auth (change nextNonce)
202     request.header(h_ProxyAuthorizations) = mLastRequest.header(h_ProxyAuthorizations);
203     }
204 jason 2725 #endif
205 jason 2621 }
206    
207 davidb 2576 InviteSession::Handle::Handle(DialogUsageManager& dum)
208 davidb 2603 : BaseUsage::Handle(dum)
209 davidb 2576 {}
210    
211 davidb 2575 InviteSession*
212     InviteSession::Handle::operator->()
213     {
214 davidb 2603 return static_cast<InviteSession*>(get());
215 davidb 2575 }
216    
217     /* ====================================================================
218     * The Vovida Software License, Version 1.0
219     *
220     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
221     *
222     * Redistribution and use in source and binary forms, with or without
223     * modification, are permitted provided that the following conditions
224     * are met:
225     *
226     * 1. Redistributions of source code must retain the above copyright
227     * notice, this list of conditions and the following disclaimer.
228     *
229     * 2. Redistributions in binary form must reproduce the above copyright
230     * notice, this list of conditions and the following disclaimer in
231     * the documentation and/or other materials provided with the
232    
233     * distribution.
234     *
235     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
236     * and "Vovida Open Communication Application Library (VOCAL)" must
237     * not be used to endorse or promote products derived from this
238     * software without prior written permission. For written
239     * permission, please contact vocal@vovida.org.
240     *
241     * 4. Products derived from this software may not be called "VOCAL", nor
242     * may "VOCAL" appear in their name, without prior written
243     * permission of Vovida Networks, Inc.
244     *
245     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
246     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
247     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
248     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
249     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
250     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
251     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
252     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
253     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
254     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
256     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
257     * DAMAGE.
258     *
259     * ====================================================================
260     *
261     * This software consists of voluntary contributions made by Vovida
262     * Networks, Inc. and many individuals on behalf of Vovida Networks,
263     * Inc. For more information on Vovida Networks, Inc., please see
264     * <http://www.vovida.org/>.
265     *
266     */

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27