AmB2BSession.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028 #ifndef AmB2BSession_h
00029 #define AmB2BSession_h
00030
00031 #include "AmSession.h"
00032 #include "AmSipDialog.h"
00033
00034 enum { B2BTerminateLeg,
00035 B2BConnectLeg,
00036 B2BCallAccepted,
00037 B2BSipRequest,
00038 B2BSipReply };
00039
00041 struct B2BEvent: public AmEvent
00042 {
00043 B2BEvent(int ev_id)
00044 : AmEvent(ev_id)
00045 {}
00046 };
00047
00049 struct B2BSipEvent: public B2BEvent
00050 {
00051 bool forward;
00052
00053 B2BSipEvent(int ev_id, bool forward)
00054 : B2BEvent(ev_id),
00055 forward(forward)
00056 {}
00057 };
00058
00060 struct B2BSipRequestEvent: public B2BSipEvent
00061 {
00062 AmSipRequest req;
00063
00064 B2BSipRequestEvent(const AmSipRequest& req, bool forward)
00065 : B2BSipEvent(B2BSipRequest,forward),
00066 req(req)
00067 {}
00068 };
00069
00071 struct B2BSipReplyEvent: public B2BSipEvent
00072 {
00073 AmSipReply reply;
00074
00075 B2BSipReplyEvent(const AmSipReply& reply, bool forward)
00076 : B2BSipEvent(B2BSipReply,forward),
00077 reply(reply)
00078 {}
00079 };
00080
00082 struct B2BConnectEvent: public B2BEvent
00083 {
00084 string remote_party;
00085 string remote_uri;
00086
00087 string content_type;
00088 string body;
00089 string hdrs;
00090
00091 bool relayed_invite;
00092 unsigned int r_cseq;
00093
00094 B2BConnectEvent(const string& remote_party,
00095 const string& remote_uri)
00096 : B2BEvent(B2BConnectLeg),
00097 remote_party(remote_party),
00098 remote_uri(remote_uri)
00099 {}
00100 };
00101
00107 class AmB2BSession: public AmSession
00108 {
00109 protected:
00111 string other_id;
00112
00117 bool sip_relay_only;
00118
00122 TransMap relayed_req;
00123
00125 std::map<int,AmSipRequest> recvd_req;
00126
00127 void clear_other();
00128
00130 virtual void relayEvent(AmEvent* ev);
00131
00132 void relaySip(const AmSipRequest& req);
00133 void relaySip(const AmSipRequest& orig, const AmSipReply& reply);
00134
00136 void terminateLeg();
00137
00139 virtual void terminateOtherLeg();
00140
00142 void onSipRequest(const AmSipRequest& req);
00143 void onSipReply(const AmSipReply& reply);
00144
00146 void process(AmEvent* event);
00147
00149 virtual void onB2BEvent(B2BEvent* ev);
00150
00151
00152 virtual void onOtherBye(const AmSipRequest& req);
00153
00159 virtual bool onOtherReply(const AmSipReply& reply);
00160
00161 AmB2BSession();
00162 AmB2BSession(const string& other_local_tag);
00163
00164 virtual ~AmB2BSession();
00165
00166 public:
00167 void set_sip_relay_only(bool r);
00168 };
00169
00170 class AmB2BCalleeSession;
00171
00173 class AmB2BCallerSession: public AmB2BSession
00174 {
00175 public:
00176 enum CalleeStatus {
00177 None=0,
00178 NoReply,
00179 Ringing,
00180 Connected
00181 };
00182
00183 private:
00184
00185 CalleeStatus callee_status;
00186
00187 int reinviteCaller(const AmSipReply& callee_reply);
00188
00189 protected:
00190 AmSipRequest invite_req;
00191 virtual void createCalleeSession();
00192 void relayEvent(AmEvent* ev);
00193
00194 public:
00195 AmB2BCallerSession();
00196 virtual ~AmB2BCallerSession();
00197
00198 CalleeStatus getCalleeStatus() { return callee_status; }
00199
00200 virtual AmB2BCalleeSession* newCalleeSession();
00201
00202 void connectCallee(const string& remote_party,
00203 const string& remote_uri,
00204 bool relayed_invite = false);
00205
00206 const AmSipRequest& getOriginalRequest() { return invite_req; }
00207
00208
00209 void onSessionStart(const AmSipRequest& req);
00210
00211
00212 void terminateLeg();
00213 void terminateOtherLeg();
00214 void onB2BEvent(B2BEvent* ev);
00215
00216 AmSipRequest* getInviteReq() { return &invite_req; }
00217
00218 };
00219
00221 class AmB2BCalleeSession: public AmB2BSession
00222 {
00223 public:
00224 AmB2BCalleeSession(const string& other_local_tag);
00225 AmB2BCalleeSession(const AmB2BCallerSession* caller);
00226
00227 virtual ~AmB2BCalleeSession();
00228
00229 void onB2BEvent(B2BEvent* ev);
00230 };
00231
00232 #endif
Generated on Fri May 16 12:02:05 2008 for SEMS by
1.5.1