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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2836 - (hide annotations) (download)
Sat May 29 23:02:23 2004 UTC (15 years, 6 months ago) by jason
Original Path: main/sip/resiprocate/dum/InviteSession.cxx
File size: 6137 byte(s)
fix interfaces on invite sessions and handlers per discussion

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

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27