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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2576 by davidb, Sun Apr 11 00:59:48 2004 UTC revision 2809 by jason, Sat May 29 02:56:14 2004 UTC
# Line 1  Line 1 
1  #include "InviteSession.hxx"  #include "resiprocate/SipMessage.hxx"
2    #include "resiprocate/dum/Dialog.hxx"
3    #include "resiprocate/dum/DialogUsageManager.hxx"
4    #include "resiprocate/dum/InviteSession.hxx"
5    
6  InviteSession::InviteSession(DialogUsageManager& dum) :  using namespace resip;
7     mDum(dum),  
8     mLocalSdp(0),  InviteSession::InviteSession(DialogUsageManager& dum, Dialog& dialog)
9     mRemoteSdp(0),     : BaseUsage(dum, dialog),
10     mMyNextOffer(0),       mOfferState(None),
11     mPendingReceivedOffer(0)       mCurrentLocalSdp(0),
12         mCurrentRemoteSdp(0),
13         mProposedLocalSdp(0),
14         mProposedRemoteSdp(0)
15  {  {
16  }  }
17    
18    SipMessage&
19    InviteSession::getOfferOrAnswer()
20    {
21       return mLastRequest;
22    }
23    
24  const SdpContents*  const SdpContents*
25  InviteSession::getLocalSdp()  InviteSession::getLocalSdp()
26  {  {
27     return mLocalSdp;     return mCurrentLocalSdp;
28  }  }
29    
30  const SdpContents*  const SdpContents*
31  InviteSession::getRemoteSdp()  InviteSession::getRemoteSdp()
32  {  {
33     return mRemoteSdp;     return mCurrentRemoteSdp;
34  }  }
35    
36  InviteSession::Handle::Handle(DialogUsageManager& dum)  SipMessage&
37     : mDum(dum)  InviteSession::end()
38  {}  {
39       //assert(mState == Connected);
40    
41    #if 0
42       // no way for the application to modify the BYE yet
43       SipMessage bye;
44       mDialog.makeBye(bye);
45       copyAuthorizations(bye);
46       //mDum.send(bye);
47    #endif
48       return mLastRequest;
49    }
50    
51    // If sdp==0, it means the last offer failed
52    void
53    InviteSession::incomingSdp(SdpContents* sdp)
54    {
55       switch (mOfferState)
56       {
57          case None:
58             assert(mCurrentLocalSdp == 0);
59             assert(mCurrentRemoteSdp == 0);
60             mProposedRemoteSdp = sdp;
61             mOfferState = Offerred;
62             break;
63            
64          case Offerred:
65             mCurrentLocalSdp = mProposedLocalSdp;
66             mCurrentRemoteSdp = sdp;
67             mProposedLocalSdp = 0;
68             mProposedRemoteSdp = 0;
69             mOfferState = Answered;
70             break;
71    
72          case Answered:
73             assert(mProposedLocalSdp == 0);
74             assert(mProposedRemoteSdp == 0);
75             mProposedRemoteSdp = sdp;
76             mOfferState = CounterOfferred;
77             break;
78            
79    
80  InviteSession::Handle::Handle(ClientInviteSession::Handle& handle)        case CounterOfferred:
81     : DialogUsageManager::Handle(handle.mDum)           assert(mCurrentLocalSdp);
82             assert(mCurrentRemoteSdp);
83             if (sdp)
84  {  {
85     mId = handle.mId;              mCurrentLocalSdp = mProposedLocalSdp;
86                mCurrentRemoteSdp = sdp;
87             }
88             else
89             {
90                mProposedLocalSdp = 0;
91                mProposedRemoteSdp = 0;
92             }
93             mOfferState = Answered;
94             break;
95       }
96  }  }
97    
98  InviteSession::Handle::Handle(ServerInviteSession::Handle& handle)  void
99     : DialogUsageManager::Handle(handle.mDum)  InviteSession::sendSdp(SdpContents* sdp)
100    {
101       switch (mOfferState)
102  {  {
103     mId = handle.mId;        case None:
104             assert(mCurrentLocalSdp == 0);
105             assert(mCurrentRemoteSdp == 0);
106             mProposedLocalSdp = sdp;
107             mOfferState = Offerred;
108             break;
109            
110          case Offerred:
111             mCurrentLocalSdp = sdp;
112             mCurrentRemoteSdp = mProposedRemoteSdp;
113             mProposedLocalSdp = 0;
114             mProposedRemoteSdp = 0;
115             mOfferState = Answered;
116             break;
117    
118          case Answered:
119             assert(mProposedLocalSdp == 0);
120             assert(mProposedRemoteSdp == 0);
121             mProposedLocalSdp = sdp;
122             mOfferState = CounterOfferred;
123             break;
124            
125            
126          case CounterOfferred:
127             assert(mCurrentLocalSdp);
128             assert(mCurrentRemoteSdp);
129             if (sdp)
130             {
131                mCurrentLocalSdp = sdp;
132                mCurrentRemoteSdp = mProposedRemoteSdp;
133  }  }
134             else
135             {
136                mProposedLocalSdp = 0;
137                mProposedRemoteSdp = 0;
138             }
139             mOfferState = Answered;
140             break;
141       }
142    }
143    
144    void
145    InviteSession::copyAuthorizations(SipMessage& request)
146    {
147    #if 0
148       if (mLastRequest.exists(h_ProxyAuthorizations))
149       {
150          // should make the next auth (change nextNonce)
151          request.header(h_ProxyAuthorizations) = mLastRequest.header(h_ProxyAuthorizations);
152       }
153       if (mLastRequest.exists(h_ProxyAuthorizations))
154       {
155          // should make the next auth (change nextNonce)
156          request.header(h_ProxyAuthorizations) = mLastRequest.header(h_ProxyAuthorizations);
157       }
158    #endif
159    }
160    
161    InviteSession::Handle::Handle(DialogUsageManager& dum)
162       : BaseUsage::Handle(dum)
163    {}
164    
165  InviteSession*  InviteSession*
166  InviteSession::Handle::operator->()  InviteSession::Handle::operator->()
167  {  {
168     return static_cast<InviteSession*>get();     return static_cast<InviteSession*>(get());
169  }  }
170    
171  /* ====================================================================  /* ====================================================================

Legend:
Removed from v.2576  
changed lines
  Added in v.2809

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27