Browse code

ported the first load of plug-ins (those which compile on osx).

Raphael Coeffic authored on 07/10/2010 18:34:03
Showing 49 changed files
... ...
@@ -51,6 +51,7 @@ clean:
51 51
 	-@for r in $(app_modules) "" ; do \
52 52
 		if [ -n "$$r" ]; then \
53 53
 			echo "" ; \
54
+			echo "Cleaning $$r" ; \
54 55
 			echo "" ; \
55 56
 			COREPATH=../$(COREPATH) $(MAKE) -C $$r clean ; \
56 57
 		fi ; \
... ...
@@ -61,6 +62,7 @@ modules:
61 62
 	-@for r in $(app_modules) "" ; do \
62 63
 		if [ -n "$$r" ]; then \
63 64
 			echo  "" ; \
65
+			echo "Making $$r" ; \
64 66
 			echo  "" ; \
65 67
 			COREPATH=../$(COREPATH) $(MAKE) -C $$r all; \
66 68
 		fi ; \
... ...
@@ -74,6 +76,7 @@ install-bin:
74 76
 	-@for r in $(app_modules) "" ; do \
75 77
 		if [ -n "$$r" ]; then \
76 78
 			echo "" ; \
79
+			echo "Installing $$r binaries" ; \
77 80
 			echo "" ; \
78 81
 			COREPATH=../$(COREPATH) $(MAKE) -C $$r install; \
79 82
 		fi ; \
... ...
@@ -84,6 +87,7 @@ install-cfg: $(DESTDIR)$(cfg-target)
84 87
 	-@for r in $(app_modules) "" ; do \
85 88
 		if [ -n "$$r" ]; then \
86 89
 			echo "" ; \
90
+			echo "Installing $$r configuration" ; \
87 91
 			echo "" ; \
88 92
 			COREPATH=../$(COREPATH) $(MAKE) -C $$r install-cfg; \
89 93
 		fi ; \
... ...
@@ -103,16 +103,17 @@ AnnounceCallerDialog::AnnounceCallerDialog(const string& filename)
103 103
   set_sip_relay_only(false);
104 104
 }
105 105
 
106
-void AnnounceCallerDialog::onSessionStart(const AmSipRequest& req)
106
+void AnnounceCallerDialog::onInvite(const AmSipRequest& req)
107 107
 {
108
-  // we can drop all received packets
109
-  // this disables DTMF detection as well
110
-  setReceiving(false);
111
-
112 108
   callee_addr = req.to;
113 109
   callee_uri  = req.r_uri;
110
+}
114 111
 
115
-  AmB2BCallerSession::onSessionStart(req);
112
+void AnnounceCallerDialog::onSessionStart()
113
+{
114
+  // we can drop all received packets
115
+  // this disables DTMF detection as well
116
+  setReceiving(false);
116 117
 
117 118
   if(wav_file.open(filename,AmAudioFile::Read))
118 119
     throw string("AnnouncementDialog::onSessionStart: Cannot open file\n");
... ...
@@ -62,7 +62,8 @@ public:
62 62
   AnnounceCallerDialog(const string& filename);
63 63
     
64 64
   void process(AmEvent* event);
65
-  void onSessionStart(const AmSipRequest& req);
65
+  void onInvite(const AmSipRequest& req);
66
+  void onSessionStart();
66 67
 };
67 68
 
68 69
 #endif
... ...
@@ -181,7 +181,7 @@ void AnnounceTransferDialog::onSipRequest(const AmSipRequest& req)
181 181
 
182 182
 }
183 183
 
184
-void AnnounceTransferDialog::onSipReply(const AmSipReply& rep, int old_dlg_status, const string& trans_method) {
184
+void AnnounceTransferDialog::onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status) {
185 185
   if ((status==Transfering ||status==Hangup)  && 
186 186
       dlg.get_uac_trans_method(rep.cseq) == "REFER") {
187 187
     if (rep.code >= 300) {
... ...
@@ -191,7 +191,7 @@ void AnnounceTransferDialog::onSipReply(const AmSipReply& rep, int old_dlg_statu
191 191
     }
192 192
   }
193 193
 
194
-  AmSession::onSipReply(rep, old_dlg_status, trans_method);
194
+  AmSession::onSipReply(rep, old_dlg_status);
195 195
 }
196 196
 
197 197
 void AnnounceTransferDialog::onBye(const AmSipRequest& req)
... ...
@@ -72,7 +72,7 @@ public:
72 72
   void startSession();
73 73
   void onBye(const AmSipRequest& req);
74 74
   void onSipRequest(const AmSipRequest& req);
75
-  void onSipReply(const AmSipReply& rep, int old_dlg_status, const string& trans_method);
75
+  void onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status);
76 76
   void onDtmf(int event, int duration_msec) {}
77 77
 
78 78
   void process(AmEvent* event);
... ...
@@ -196,13 +196,13 @@ bool AuthB2BDialog::onOtherReply(const AmSipReply& reply)
196 196
 //         m_user_timer->invoke("setTimer", di_args, ret);
197 197
       }
198 198
     }
199
-    else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) {
199
+    else if(reply.code == 487 && (dlg.getStatus() < AmSipDialog::Connected)) {
200 200
       DBG("Stopping leg A on 487 from B with 487\n");
201 201
       dlg.reply(invite_req, 487, "Request terminated");
202 202
       setStopped();
203 203
       ret = true;
204 204
     }
205
-    else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) {
205
+    else if (dlg.getStatus() == AmSipDialog::Connected) {
206 206
       DBG("Callee final error in connected state with code %d\n",reply.code);
207 207
       terminateLeg();
208 208
     }
... ...
@@ -234,11 +234,8 @@ void AuthB2BDialog::onBye(const AmSipRequest& req)
234 234
 
235 235
 void AuthB2BDialog::onCancel()
236 236
 {
237
-  if(dlg.getStatus() == AmSipDialog::Pending) {
238
-    DBG("Wait for leg B to terminate");
239
-  }
240
-  else {
241
-    DBG("Canceling leg A on CANCEL since dialog is not pending");
237
+  if(dlg.getStatus() == AmSipDialog::Cancelling) {
238
+    terminateOtherLeg();
242 239
     dlg.reply(invite_req, 487, "Request terminated");
243 240
     setStopped();
244 241
   }
... ...
@@ -313,15 +310,15 @@ inline UACAuthCred* AuthB2BCalleeSession::getCredentials() {
313 310
   return &credentials;
314 311
 }
315 312
 
316
-void AuthB2BCalleeSession::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method) {
313
+void AuthB2BCalleeSession::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status) {
317 314
   if (NULL == auth) {    
318
-    AmB2BCalleeSession::onSipReply(reply,old_dlg_status,trans_method);
315
+    AmB2BCalleeSession::onSipReply(reply,old_dlg_status);
319 316
     return;
320 317
   }
321 318
   
322 319
   unsigned int cseq_before = dlg.cseq;
323
-  if (!auth->onSipReply(reply, old_dlg_status,trans_method)) {
324
-    AmB2BCalleeSession::onSipReply(reply,old_dlg_status,trans_method);
320
+  if (!auth->onSipReply(reply, old_dlg_status)) {
321
+    AmB2BCalleeSession::onSipReply(reply,old_dlg_status);
325 322
   } else {
326 323
     if (cseq_before != dlg.cseq) {
327 324
       DBG("uac_auth consumed reply with cseq %d and resent with cseq %d; "
... ...
@@ -95,7 +95,7 @@ class AuthB2BCalleeSession
95 95
   AmSessionEventHandler* auth;
96 96
 
97 97
  protected:
98
-  void onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method);
98
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
99 99
   void onSendRequest(const string& method, const string& content_type,
100 100
 		     const string& body, string& hdrs, int flags, unsigned int cseq);
101 101
 
... ...
@@ -198,17 +198,17 @@ bool CallTimerDialog::onOtherReply(const AmSipReply& reply)
198 198
         m_user_timer->invoke("setTimer", di_args, ret);
199 199
       }
200 200
     }
201
-    else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) {
201
+    else if(reply.code == 487 && dlg.getStatus() < AmSipDialog::Connected) {
202 202
       DBG("Stopping leg A on 487 from B with 487\n");
203 203
       dlg.reply(invite_req, 487, "Request terminated");
204 204
       setStopped();
205 205
       ret = true;
206 206
     }
207
-    else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) {
207
+    else if (dlg.getStatus() == AmSipDialog::Connected) {
208 208
       DBG("Callee final error in connected state with code %d\n",reply.code);
209 209
       terminateLeg();
210 210
     }
211
-    else if (reply.code >= 300 && m_state == BB_Dialing) {
211
+    else if (m_state == BB_Dialing) {
212 212
       DBG("Callee final error with code %d\n",reply.code);
213 213
       AmB2BCallerSession::onOtherReply(reply);
214 214
       // reset into non-b2b mode to get possible INVITE again
... ...
@@ -241,11 +241,8 @@ void CallTimerDialog::onBye(const AmSipRequest& req)
241 241
 
242 242
 void CallTimerDialog::onCancel()
243 243
 {
244
-  if(dlg.getStatus() == AmSipDialog::Pending) {
245
-    DBG("Wait for leg B to terminate");
246
-  }
247
-  else {
248
-    DBG("Canceling leg A on CANCEL since dialog is not pending");
244
+  if(dlg.getStatus() == AmSipDialog::Cancelling) {
245
+    terminateOtherLeg();
249 246
     dlg.reply(invite_req, 487, "Request terminated");
250 247
     setStopped();
251 248
   }
... ...
@@ -238,10 +238,11 @@ CallBackDialog::~CallBackDialog()
238 238
 }
239 239
 
240 240
 
241
-void CallBackDialog::onSessionStart(const AmSipRequest& req) { 
241
+void CallBackDialog::onInvite(const AmSipRequest& req) 
242
+{ 
242 243
   if (state != CBNone) {
243 244
     // reinvite
244
-    AmB2ABCallerSession::onSessionStart(req);
245
+    AmB2ABCallerSession::onInvite(req);
245 246
     return;
246 247
   }
247 248
 
... ...
@@ -250,7 +251,8 @@ void CallBackDialog::onSessionStart(const AmSipRequest& req) {
250 251
   dlg.bye();
251 252
 }
252 253
 
253
-void CallBackDialog::onSessionStart(const AmSipReply& rep) { 
254
+void CallBackDialog::onSessionStart() 
255
+{ 
254 256
   state = CBEnteringNumber;    
255 257
   prompts.addToPlaylist(WELCOME_PROMPT,  (long)this, play_list);
256 258
   // set the playlist as input and output
... ...
@@ -111,8 +111,8 @@ public:
111 111
   ~CallBackDialog();
112 112
 
113 113
   void process(AmEvent* ev);
114
-  void onSessionStart(const AmSipRequest& req);
115
-  void onSessionStart(const AmSipReply& rep);
114
+  void onInvite(const AmSipRequest& req); 
115
+  void onSessionStart();
116 116
   void onDtmf(int event, int duration);
117 117
 
118 118
   UACAuthCred* getCredentials() { return cred; }
... ...
@@ -795,15 +795,17 @@ void ConferenceDialog::createDialoutParticipant(const string& uri_user)
795 795
   dialout_dlg.remote_party = uri;
796 796
   dialout_dlg.remote_uri   = uri;
797 797
 
798
-  string body;
799
-  int local_port = dialout_session->RTPStream()->getLocalPort();
800
-  dialout_session->sdp.genRequest(AmConfig::LocalIP,local_port,body);
798
+  //string body;
799
+  //int local_port = dialout_session->RTPStream()->getLocalPort();
800
+  //dialout_session->sdp.genRequest(AmConfig::LocalIP,local_port,body);
801 801
 
802 802
   if (extra_headers.length() == 0) {
803 803
     extra_headers = "";
804 804
   }
805 805
 
806
-  dialout_dlg.sendRequest("INVITE","application/sdp",body,extra_headers);
806
+  dialout_dlg.sendRequest("INVITE",
807
+			  "",""/*"application/sdp",body*/,
808
+			  extra_headers);
807 809
 
808 810
   dialout_session->start();
809 811
 
... ...
@@ -885,20 +887,22 @@ void ConferenceDialog::onSipRequest(const AmSipRequest& req)
885 887
   DBG("ConferenceDialog::onSipRequest: remote_party = %s\n",dlg.remote_party.c_str());
886 888
   DBG("ConferenceDialog::onSipRequest: remote_tag = %s\n",dlg.remote_tag.c_str());
887 889
 
888
-  string body;
889
-  int local_port = RTPStream()->getLocalPort();
890
-  sdp.genRequest(AmConfig::LocalIP,local_port,body);
891
-  dlg.sendRequest("INVITE","application/sdp",body,"");
890
+  //string body;
891
+  //int local_port = RTPStream()->getLocalPort();
892
+  //sdp.genRequest(AmConfig::LocalIP,local_port,body);
893
+  dlg.sendRequest("INVITE",
894
+ 		  "","",//"application/sdp",body,
895
+ 		  "");
892 896
 
893 897
   transfer_req.reset(new AmSipRequest(req));
894 898
 
895 899
   return;
896 900
 }
897 901
 
898
-void ConferenceDialog::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method)
902
+void ConferenceDialog::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
899 903
 {
900
-  int status = dlg.getStatus();
901
-  AmSession::onSipReply(reply, old_dlg_status, trans_method);
904
+  //int status = dlg.getStatus();
905
+  AmSession::onSipReply(reply, old_dlg_status);
902 906
 
903 907
   DBG("ConferenceDialog::onSipReply: code = %i, reason = %s\n, status = %i\n",
904 908
       reply.code,reply.reason.c_str(),dlg.getStatus());
... ...
@@ -907,6 +911,7 @@ void ConferenceDialog::onSipReply(const AmSipReply& reply, int old_dlg_status, c
907 911
      !transfer_req.get())
908 912
     return;
909 913
 
914
+  /*
910 915
   if(status < AmSipDialog::Connected){
911 916
 
912 917
     switch(dlg.getStatus()){
... ...
@@ -992,13 +997,10 @@ void ConferenceDialog::onSipReply(const AmSipReply& reply, int old_dlg_status, c
992 997
       }
993 998
       break;
994 999
 
995
-	    
996
-
997 1000
     default: break;
998 1001
     }
999
-
1000
-
1001 1002
   }
1003
+  */
1002 1004
 }
1003 1005
 
1004 1006
 #ifdef WITH_SAS_TTS
... ...
@@ -157,8 +157,7 @@ public:
157 157
   void onBye(const AmSipRequest& req);
158 158
 
159 159
   void onSipRequest(const AmSipRequest& req);
160
-  void onSipReply(const AmSipReply& reply, int old_dlg_status,
161
-		  const string& trans_method);
160
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
162 161
 
163 162
 #ifdef WITH_SAS_TTS
164 163
   void onZRTPEvent(zrtp_event_t event, zrtp_stream_ctx_t *stream_ctx);
... ...
@@ -688,19 +688,19 @@ AmSession* DSMFactory::onInvite(const AmSipRequest& req)
688 688
   string start_diag;
689 689
   map<string, string> vars;
690 690
 
691
-  if (req.cmd == MOD_NAME) {
692
-    if (InboundStartDiag.empty()) {
693
-      ERROR("no inbound calls allowed\n");
694
-      throw AmSession::Exception(488, "Not Acceptable Here");
695
-    }
696
-    if (InboundStartDiag=="$(mon_select)") {
697
-      runMonitorAppSelect(req, start_diag, vars);
698
-    } else {
699
-      start_diag = InboundStartDiag;
700
-    }
691
+  //if (req.cmd == MOD_NAME) {
692
+  if (InboundStartDiag.empty()) {
693
+    ERROR("no inbound calls allowed\n");
694
+    throw AmSession::Exception(488, "Not Acceptable Here");
695
+  }
696
+  if (InboundStartDiag=="$(mon_select)") {
697
+    runMonitorAppSelect(req, start_diag, vars);
701 698
   } else {
702
-    start_diag = req.cmd;
699
+    start_diag = InboundStartDiag;
703 700
   }
701
+  //} else {
702
+  //start_diag = req.cmd;
703
+  //}
704 704
 
705 705
   // determine run configuration for script
706 706
   DSMScriptConfig call_config;
... ...
@@ -734,14 +734,14 @@ AmSession* DSMFactory::onInvite(const AmSipRequest& req,
734 734
 
735 735
   string start_diag;
736 736
 
737
-  if (req.cmd == MOD_NAME) {
738
-    if (OutboundStartDiag.empty()) {
739
-      ERROR("no outbound calls allowed\n");
737
+  //if (req.cmd == MOD_NAME) {
738
+  if (OutboundStartDiag.empty()) {
739
+    ERROR("no outbound calls allowed\n");
740 740
     throw AmSession::Exception(488, "Not Acceptable Here");
741
-    }
742
-  } else {
743
-    start_diag = req.cmd;
744 741
   }
742
+  //} else {
743
+  //start_diag = req.cmd;
744
+  //}
745 745
 
746 746
   UACAuthCred* cred = NULL;
747 747
   map<string, string> vars;
... ...
@@ -169,17 +169,24 @@ void DSMCall::onEarlySessionStart(const AmSipReply& reply) {
169 169
   }
170 170
 }
171 171
 
172
-void DSMCall::onSessionStart(const AmSipRequest& req)
172
+void DSMCall::onSessionStart()
173 173
 {
174 174
   if (process_sessionstart) {
175 175
     process_sessionstart = false;
176
-    AmB2BCallerSession::onSessionStart(req);
176
+    AmB2BCallerSession::onSessionStart();
177 177
 
178 178
     DBG("DSMCall::onSessionStart\n");
179 179
     startSession();
180 180
   }
181 181
 }
182 182
 
183
+int DSMCall::onSdpCompleted(const AmSdp& offer, const AmSdp& answer)
184
+{
185
+  answer.print(invite_req.body);
186
+  return AmB2BCallerSession::onSdpCompleted(offer,answer);
187
+}
188
+
189
+/*
183 190
 void DSMCall::onSessionStart(const AmSipReply& rep)
184 191
 {
185 192
   if (process_sessionstart) {
... ...
@@ -190,6 +197,7 @@ void DSMCall::onSessionStart(const AmSipReply& rep)
190 197
     startSession();    
191 198
   }
192 199
 }
200
+*/
193 201
 
194 202
 void DSMCall::startSession(){
195 203
   engine.init(this, this, startDiagName, DSMCondition::SessionStart);
... ...
@@ -287,7 +295,7 @@ void DSMCall::onSipRequest(const AmSipRequest& req) {
287 295
   AmB2BCallerSession::onSipRequest(req);  
288 296
 }
289 297
 
290
-void DSMCall::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method) {
298
+void DSMCall::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status) {
291 299
 
292 300
   if (checkVar(DSM_ENABLE_REPLY_EVENTS, DSM_TRUE)) {
293 301
     map<string, string> params;
... ...
@@ -318,7 +326,7 @@ void DSMCall::onSipReply(const AmSipReply& reply, int old_dlg_status, const stri
318 326
     }
319 327
   }
320 328
 
321
-  AmB2BCallerSession::onSipReply(reply,old_dlg_status,trans_method);
329
+  AmB2BCallerSession::onSipReply(reply,old_dlg_status);
322 330
 
323 331
   if ((old_dlg_status < AmSipDialog::Connected) && 
324 332
       (dlg.getStatus() == AmSipDialog::Disconnected)) {
... ...
@@ -75,15 +75,15 @@ public:
75 75
   void onOutgoingInvite(const string& headers);
76 76
   void onRinging(const AmSipReply& reply);
77 77
   void onEarlySessionStart(const AmSipReply& reply);
78
-  void onSessionStart(const AmSipRequest& req);
79
-  void onSessionStart(const AmSipReply& rep);
78
+  void onSessionStart();
79
+  int  onSdpCompleted(const AmSdp& offer, const AmSdp& answer);
80 80
   void startSession();
81 81
   void onCancel();
82 82
   void onBye(const AmSipRequest& req);
83 83
   void onDtmf(int event, int duration_msec);
84 84
 
85 85
   void onSipRequest(const AmSipRequest& req);
86
-  void onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method);
86
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
87 87
 
88 88
   void process(AmEvent* event);
89 89
 
... ...
@@ -137,8 +137,8 @@ EXEC_ACTION_START(DLGAcceptInviteAction) {
137 137
   try {
138 138
     string sdp_reply;
139 139
 
140
-    sess->acceptAudio(sc_sess->last_req.get()->body,
141
-		      sc_sess->last_req.get()->hdrs,&sdp_reply);
140
+    // sess->acceptAudio(sc_sess->last_req.get()->body,
141
+    // 		      sc_sess->last_req.get()->hdrs,&sdp_reply);
142 142
     if(sess->dlg.reply(*sc_sess->last_req.get(),code_i, reason,
143 143
 		 "application/sdp",sdp_reply) != 0)
144 144
       throw AmSession::Exception(500,"could not send response");
... ...
@@ -271,12 +271,8 @@ int EarlyAnnounceFactory::onLoad()
271 271
 void EarlyAnnounceDialog::onInvite(const AmSipRequest& req) 
272 272
 {
273 273
   try {
274
-
275
-    string sdp_reply;
276
-    acceptAudio(req.body,req.hdrs,&sdp_reply);
277
-
278 274
     if(dlg.reply(req,183,"Session Progress",
279
-		 "application/sdp",sdp_reply) != 0){
275
+		 "application/sdp") != 0){
280 276
 
281 277
       throw AmSession::Exception(500,"could not reply");
282 278
     }
... ...
@@ -287,9 +287,9 @@ inline UACAuthCred* b2b_connectCalleeSession::getCredentials() {
287 287
 }
288 288
 
289 289
 void b2b_connectCalleeSession::onSipReply(const AmSipReply& reply,
290
-					  int old_dlg_status,
291
-					  const string& trans_method) {
292
-  AmB2ABCalleeSession::onSipReply(reply, old_dlg_status, trans_method);
290
+					  AmSipDialog::Status old_dlg_status) {
291
+
292
+  AmB2ABCalleeSession::onSipReply(reply, old_dlg_status);
293 293
  
294 294
   if ((old_dlg_status == AmSipDialog::Pending)&&
295 295
       (dlg.getStatus() == AmSipDialog::Disconnected)) {
... ...
@@ -88,8 +88,7 @@ class b2b_connectCalleeSession
88 88
   AmSipRequest invite_req;
89 89
 
90 90
  protected:
91
-  void onSipReply(const AmSipReply& reply, int old_dlg_status,
92
-		  const string& trans_method);
91
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
93 92
  
94 93
 public:
95 94
   b2b_connectCalleeSession(const string& other_tag, 
... ...
@@ -90,7 +90,7 @@ void GWSession::onSipRequest(const AmSipRequest& req)
90 90
   }
91 91
 }
92 92
 
93
-void GWSession::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method) {
93
+void GWSession::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status) {
94 94
     int status = dlg.getStatus();
95 95
     DBG("GWSession::onSipReply: code = %i, reason = %s\n, status = %i\n",  
96 96
 	reply.code,reply.reason.c_str(),dlg.getStatus());
... ...
@@ -99,7 +99,7 @@ void GWSession::onSipReply(const AmSipReply& reply, int old_dlg_status, const st
99 99
 	int ret=((mISDNChannel*)m_OtherLeg)->hangup();
100 100
     }
101 101
     DBG("GWSession::onSipReply calling parent\n");
102
-    AmSession::onSipReply(reply, old_dlg_status, trans_method);
102
+    AmSession::onSipReply(reply, old_dlg_status);
103 103
 }
104 104
 
105 105
 void GWSession::on_stop() {
... ...
@@ -33,7 +33,7 @@ static    GWSession* CallFromOutside(std::string &fromnumber, std::string &tonum
33 33
   void onBye(const AmSipRequest& req);
34 34
 //virtual void onSipEvent(AmSipEvent* sip_ev);
35 35
   void onSipRequest(const AmSipRequest& req);
36
-  void onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method);
36
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
37 37
 //virtual void onRtpTimeout();
38 38
 //virtual void onSendRequest(const string& method, const string& content_type, const string& body, string& hdrs, int flags, unsigned int cseq);
39 39
 //virtual void onSendReply(const AmSipRequest& req, unsigned int code,const string& reason,const string& content_type, const string& body,string& hdrs,int flags)
... ...
@@ -567,10 +567,10 @@ void IvrFactory::setupSessionTimer(AmSession* s) {
567 567
  */
568 568
 AmSession* IvrFactory::onInvite(const AmSipRequest& req)
569 569
 {
570
-  if(req.cmd != MOD_NAME)
571
-    return newDlg(req.cmd);
572
-  else
573
-    return newDlg(req.user);
570
+  // if(req.cmd != MOD_NAME)
571
+  //   return newDlg(req.cmd);
572
+  // else
573
+  return newDlg(req.user);
574 574
 }
575 575
 
576 576
 IvrDialog::IvrDialog(AmDynInvoke* user_timer)
... ...
@@ -695,19 +695,22 @@ bool IvrDialog::callPyEventHandler(char* name, char* fmt, ...)
695 695
   return ret;
696 696
 }
697 697
 
698
-void IvrDialog::onSessionStart(const AmSipRequest& req)
698
+void IvrDialog::onInvite(const AmSipRequest& req)
699 699
 {
700
-  callPyEventHandler("onSessionStart","(s)",req.hdrs.c_str());
701
-  setInOut(&playlist,&playlist);
702
-  AmB2BCallerSession::onSessionStart(req);
700
+  callPyEventHandler("onInvite","(s)",req.hdrs.c_str());
703 701
 }
704 702
 
705
-void IvrDialog::onSessionStart(const AmSipReply& rep)
703
+void IvrDialog::onSessionStart()
706 704
 {
707
-  invite_req.body = rep.body;
708
-  callPyEventHandler("onSessionStart","(s)",rep.hdrs.c_str());
705
+  callPyEventHandler("onSessionStart",NULL);
709 706
   setInOut(&playlist,&playlist);
710
-  AmB2BSession::onSessionStart(rep);
707
+  AmB2BCallerSession::onSessionStart();
708
+}
709
+
710
+int IvrDialog::onSdpCompleted(const AmSdp& offer, const AmSdp& answer)
711
+{
712
+  answer.print(invite_req.body);
713
+  return AmB2BCallerSession::onSdpCompleted(offer,answer);
711 714
 }
712 715
 
713 716
 void IvrDialog::onBye(const AmSipRequest& req)
... ...
@@ -753,11 +756,11 @@ void safe_Py_DECREF(PyObject* pyo) {
753 756
   Py_DECREF(pyo);
754 757
 }
755 758
 
756
-void IvrDialog::onSipReply(const AmSipReply& r, int old_dlg_status, const string& trans_method) {
759
+void IvrDialog::onSipReply(const AmSipReply& r, AmSipDialog::Status old_dlg_status) {
757 760
   PyObject* pyo = getPySipReply(r);
758 761
   callPyEventHandler("onSipReply","(O)", pyo);
759 762
   safe_Py_DECREF(pyo);
760
-  AmB2BSession::onSipReply(r,old_dlg_status,trans_method);
763
+  AmB2BSession::onSipReply(r,old_dlg_status);
761 764
 }
762 765
 
763 766
 void IvrDialog::onSipRequest(const AmSipRequest& r){
... ...
@@ -145,8 +145,9 @@ class IvrDialog : public AmB2BCallerSession
145 145
   int transfer(const string& target);
146 146
   int drop();
147 147
     
148
-  void onSessionStart(const AmSipRequest& req);
149
-  void onSessionStart(const AmSipReply& rep);
148
+  void onInvite(const AmSipRequest& req);
149
+  int  onSdpCompleted(const AmSdp& offer, const AmSdp& answer);
150
+  void onSessionStart();
150 151
 
151 152
   void onBye(const AmSipRequest& req);
152 153
   void onDtmf(int event, int duration_msec);
... ...
@@ -154,7 +155,7 @@ class IvrDialog : public AmB2BCallerSession
154 155
   void onOtherBye(const AmSipRequest& req);
155 156
   bool onOtherReply(const AmSipReply& r);
156 157
 
157
-  void onSipReply(const AmSipReply& r,int old_dlg_status, const string& trans_method);
158
+  void onSipReply(const AmSipReply& r,AmSipDialog::Status old_dlg_status);
158 159
   void onSipRequest(const AmSipRequest& r);
159 160
 
160 161
   void onRtpTimeout();
... ...
@@ -77,12 +77,12 @@ IvrSipReply_dealloc(IvrSipReply* self)
77 77
 								
78 78
 								
79 79
 def_IvrSipReply_GETTER(IvrSipReply_getreason,     reason)
80
-def_IvrSipReply_GETTER(IvrSipReply_getnext_request_uri, next_request_uri)
81
-def_IvrSipReply_GETTER(IvrSipReply_gethdrs,         hdrs)
82
-def_IvrSipReply_GETTER(IvrSipReply_getremote_tag,   remote_tag)
83
-def_IvrSipReply_GETTER(IvrSipReply_getlocal_tag,    local_tag)
84
-def_IvrSipReply_GETTER(IvrSipReply_getroute,        route)
85
-def_IvrSipReply_GETTER(IvrSipReply_getbody,         body)
80
+//def_IvrSipReply_GETTER(IvrSipReply_getnext_request_uri, next_request_uri)
81
+def_IvrSipReply_GETTER(IvrSipReply_gethdrs,       hdrs)
82
+def_IvrSipReply_GETTER(IvrSipReply_getfrom_tag,   from_tag)
83
+def_IvrSipReply_GETTER(IvrSipReply_getto_tag,     to_tag)
84
+def_IvrSipReply_GETTER(IvrSipReply_getroute,      route)
85
+def_IvrSipReply_GETTER(IvrSipReply_getbody,       body)
86 86
 
87 87
 static PyObject*
88 88
 IvrSipReply_getcseq(IvrSipReply *self, void *closure)
... ...
@@ -99,13 +99,13 @@ IvrSipReply_getcode(IvrSipReply *self, void *closure)
99 99
 static PyGetSetDef IvrSipReply_getset[] = {
100 100
   {"code",          (getter)IvrSipReply_getcode, NULL, "code", NULL},
101 101
   {"reason",        (getter)IvrSipReply_getreason, NULL, "reason", NULL},
102
-  {"next_request_uri",        (getter)IvrSipReply_getnext_request_uri, NULL, "next_request_uri", NULL},
102
+  //{"next_request_uri",        (getter)IvrSipReply_getnext_request_uri, NULL, "next_request_uri", NULL},
103 103
   {"route",          (getter)IvrSipReply_getroute, NULL, "route", NULL},
104 104
   {"hdrs",         (getter)IvrSipReply_gethdrs, NULL, "hdrs", NULL},
105 105
   {"body",      (getter)IvrSipReply_getbody, NULL, "body", NULL},
106
-  {"remote_tag",          (getter)IvrSipReply_getremote_tag, NULL, "remote_tag", NULL},
107
-  {"local_tag",            (getter)IvrSipReply_getlocal_tag, NULL, "local_tag", NULL},
108
-  {"cseq",    (getter)IvrSipReply_getcseq, NULL, "CSeq for next request", NULL},
106
+  {"from_tag",          (getter)IvrSipReply_getfrom_tag, NULL, "from_tag", NULL},
107
+  {"to_tag",            (getter)IvrSipReply_getto_tag, NULL, "to_tag", NULL},
108
+  {"cseq",    (getter)IvrSipReply_getcseq, NULL, "cseq", NULL},
109 109
   {NULL}  /* Sentinel */
110 110
 };
111 111
 
... ...
@@ -53,7 +53,7 @@ SIPRegistration::SIPRegistration(const string& handle,
53 53
 				 const SIPRegistrationInfo& info,
54 54
 				 const string& sess_link) 
55 55
   : info(info),
56
-    dlg(this),
56
+    dlg(NULL),
57 57
     cred(info.domain, info.auth_user, info.pwd),
58 58
     active(false),
59 59
     reg_begin(0),
... ...
@@ -64,7 +64,7 @@ SIPRegistration::SIPRegistration(const string& handle,
64 64
     waiting_result(false),
65 65
     seh(NULL)
66 66
 {
67
-  req.cmd      = "sems";
67
+  //req.cmd      = "sems";
68 68
   req.user     = info.user;
69 69
   req.method   = "REGISTER";
70 70
   req.r_uri    = "sip:"+info.domain;
... ...
@@ -77,7 +77,7 @@ SIPRegistration::SIPRegistration(const string& handle,
77 77
   //
78 78
 
79 79
   // clear dlg.callid? ->reregister?
80
-  dlg.updateStatusFromLocalRequest(req);
80
+  dlg.initFromLocalRequest(req);
81 81
   dlg.cseq = 50;
82 82
 }
83 83
 
... ...
@@ -348,10 +348,11 @@ void SIPRegistrarClient::process(AmEvent* ev)
348 348
 
349 349
 }
350 350
 
351
-void SIPRegistrarClient::onSipReplyEvent(AmSipReplyEvent* ev) {
352
-  SIPRegistration* reg = get_reg(ev->reply.local_tag);
351
+void SIPRegistrarClient::onSipReplyEvent(AmSipReplyEvent* ev) 
352
+{
353
+  SIPRegistration* reg = get_reg(ev->reply.from_tag);
353 354
   if (reg != NULL) {
354
-      reg->getDlg()->updateStatus(ev->reply);//onSipReply(ev->reply);
355
+      reg->onSipReply(ev->reply);
355 356
   }
356 357
 }
357 358
 
... ...
@@ -369,9 +370,9 @@ bool SIPRegistration::registerExpired(time_t now_sec) {
369 370
   return ((reg_begin+reg_expires) < (unsigned int)now_sec);	
370 371
 }
371 372
 
372
-void SIPRegistration::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method)
373
+void SIPRegistration::onSipReply(const AmSipReply& reply)
373 374
 {
374
-  if ((seh!=NULL) && seh->onSipReply(reply, old_dlg_status, trans_method))
375
+  if ((seh!=NULL) && seh->onSipReply(reply, dlg.getStatus()))
375 376
     return;
376 377
 
377 378
   waiting_result = false;
... ...
@@ -498,10 +499,10 @@ void SIPRegistrarClient::onRemoveRegistration(SIPRemoveRegistrationEvent* new_re
498 499
 void SIPRegistrarClient::on_stop() { }
499 500
 
500 501
 
501
-bool SIPRegistrarClient::onSipReply(const AmSipReply& rep, int old_dlg_status, const string& trans_method) {
502
-  DBG("got reply with tag '%s'\n", rep.local_tag.c_str());
502
+bool SIPRegistrarClient::onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status) {
503
+  DBG("got reply with tag '%s'\n", rep.from_tag.c_str());
503 504
 	
504
-  if (instance()->hasRegistration(rep.local_tag)) {
505
+  if (instance()->hasRegistration(rep.from_tag)) {
505 506
     instance()->postEvent(new AmSipReplyEvent(rep));
506 507
     return true;
507 508
   } else 
... ...
@@ -61,7 +61,7 @@ struct SIPRegistrationInfo {
61 61
   { }
62 62
 };
63 63
 
64
-class SIPRegistration : public AmSipDialogEventHandler,
64
+class SIPRegistration : //public AmSipDialogEventHandler,
65 65
 			public DialogControl,
66 66
 			public CredentialHolder
67 67
 	
... ...
@@ -124,7 +124,7 @@ class SIPRegistration : public AmSipDialogEventHandler,
124 124
   // CredentialHolder	
125 125
   UACAuthCred* getCredentials() { return &cred; }
126 126
 
127
-  void onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method);
127
+  void onSipReply(const AmSipReply& reply);
128 128
   void onSipRequest(const AmSipRequest& req) {}
129 129
   void onInvite2xx(const AmSipReply&) {}
130 130
   void onNoAck(unsigned int) {}
... ...
@@ -192,7 +192,7 @@ class SIPRegistrarClient  : public AmThread,
192 192
   void invoke(const string& method, 
193 193
 	      const AmArg& args, AmArg& ret);
194 194
 	
195
-  bool onSipReply(const AmSipReply& rep, int old_dlg_status, const string& trans_method);
195
+  bool onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status);
196 196
   int onLoad();
197 197
 	
198 198
   void run();
... ...
@@ -156,8 +156,7 @@ void SSTB2BDialog::onSipRequest(const AmSipRequest& req) {
156 156
   AmB2BCallerSession::onSipRequest(req);
157 157
 }
158 158
 
159
-void SSTB2BDialog::onSipReply(const AmSipReply& reply, int old_dlg_status,
160
-			      const string& trans_method)
159
+void SSTB2BDialog::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
161 160
 {
162 161
   TransMap::iterator t = relayed_req.find(reply.cseq);
163 162
   bool fwd = t != relayed_req.end();
... ...
@@ -165,10 +164,10 @@ void SSTB2BDialog::onSipReply(const AmSipReply& reply, int old_dlg_status,
165 164
   DBG("onSipReply: %i %s (fwd=%i)\n",reply.code,reply.reason.c_str(),fwd);
166 165
   DBG("onSipReply: content-type = %s\n",reply.content_type.c_str());
167 166
   if (fwd) {
168
-      CALL_EVENT_H(onSipReply,reply, old_dlg_status, trans_method);
167
+      CALL_EVENT_H(onSipReply,reply, old_dlg_status);
169 168
   }
170 169
 
171
-  AmB2BCallerSession::onSipReply(reply,old_dlg_status, trans_method);
170
+  AmB2BCallerSession::onSipReply(reply,old_dlg_status);
172 171
 }
173 172
 
174 173
 bool SSTB2BDialog::onOtherReply(const AmSipReply& reply)
... ...
@@ -185,13 +184,13 @@ bool SSTB2BDialog::onOtherReply(const AmSipReply& reply)
185 184
         setInOut(NULL, NULL);
186 185
       }
187 186
     }
188
-    else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) {
187
+    else if(reply.code == 487 && dlg.getStatus() < AmSipDialog::Connected) {
189 188
       DBG("Stopping leg A on 487 from B with 487\n");
190 189
       dlg.reply(invite_req, 487, "Request terminated");
191 190
       setStopped();
192 191
       ret = true;
193 192
     }
194
-    else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) {
193
+    else if (dlg.getStatus() == AmSipDialog::Connected) {
195 194
       DBG("Callee final error in connected state with code %d\n",reply.code);
196 195
       terminateLeg();
197 196
     }
... ...
@@ -223,10 +222,8 @@ void SSTB2BDialog::onBye(const AmSipRequest& req)
223 222
 
224 223
 void SSTB2BDialog::onCancel()
225 224
 {
226
-  if(dlg.getStatus() == AmSipDialog::Pending) {
227
-    DBG("Wait for leg B to terminate");
228
-  } else {
229
-    DBG("Canceling leg A on CANCEL since dialog is not pending");
225
+  if(dlg.getStatus() == AmSipDialog::Cancelling) {
226
+    terminateOtherLeg();
230 227
     dlg.reply(invite_req, 487, "Request terminated");
231 228
     setStopped();
232 229
   }
... ...
@@ -282,12 +279,12 @@ void SSTB2BDialog::createCalleeSession()
282 279
       from.c_str());
283 280
 
284 281
   if (AmConfig::LogSessions) {
285
-    INFO("Starting B2B callee session %s app %s\n",
286
-	 callee_session->getLocalTag().c_str(), invite_req.cmd.c_str());
282
+    INFO("Starting B2B callee session %s\n",
283
+	 callee_session->getLocalTag().c_str());
287 284
   }
288 285
 
289
-  MONITORING_LOG5(other_id.c_str(), 
290
-		  "app",  invite_req.cmd.c_str(),
286
+  MONITORING_LOG4(other_id.c_str(), 
287
+		  // "app",  invite_req.cmd.c_str(),
291 288
 		  "dir",  "out",
292 289
 		  "from", callee_dlg.local_party.c_str(),
293 290
 		  "to",   callee_dlg.remote_party.c_str(),
... ...
@@ -330,8 +327,7 @@ void SSTB2BCalleeSession::onSipRequest(const AmSipRequest& req) {
330 327
   AmB2BCalleeSession::onSipRequest(req);
331 328
 }
332 329
 
333
-void SSTB2BCalleeSession::onSipReply(const AmSipReply& reply, int old_dlg_status,
334
-				     const string& trans_method)
330
+void SSTB2BCalleeSession::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
335 331
 {
336 332
   // call event handlers where it is not done 
337 333
   TransMap::iterator t = relayed_req.find(reply.cseq);
... ...
@@ -339,17 +335,17 @@ void SSTB2BCalleeSession::onSipReply(const AmSipReply& reply, int old_dlg_status
339 335
   DBG("onSipReply: %i %s (fwd=%i)\n",reply.code,reply.reason.c_str(),fwd);
340 336
   DBG("onSipReply: content-type = %s\n",reply.content_type.c_str());
341 337
   if(fwd) {
342
-    CALL_EVENT_H(onSipReply,reply, old_dlg_status, trans_method);
338
+    CALL_EVENT_H(onSipReply,reply, old_dlg_status);
343 339
   }
344 340
 
345 341
   if (NULL == auth) {    
346
-    AmB2BCalleeSession::onSipReply(reply,old_dlg_status, trans_method);
342
+    AmB2BCalleeSession::onSipReply(reply,old_dlg_status);
347 343
     return;
348 344
   }
349 345
   
350 346
   unsigned int cseq_before = dlg.cseq;
351
-  if (!auth->onSipReply(reply, old_dlg_status, trans_method)) {
352
-      AmB2BCalleeSession::onSipReply(reply, old_dlg_status, trans_method);
347
+  if (!auth->onSipReply(reply, old_dlg_status)) {
348
+      AmB2BCalleeSession::onSipReply(reply, old_dlg_status);
353 349
   } else {
354 350
     if (cseq_before != dlg.cseq) {
355 351
       DBG("uac_auth consumed reply with cseq %d and resent with cseq %d; "
... ...
@@ -91,8 +91,7 @@ class SSTB2BDialog : public AmB2BCallerSession
91 91
   void onCancel();
92 92
 
93 93
  protected:
94
-  void onSipReply(const AmSipReply& reply, int old_dlg_status,
95
-		  const string& trans_method);
94
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
96 95
   void onSipRequest(const AmSipRequest& req);  
97 96
 
98 97
  protected:
... ...
@@ -114,8 +113,7 @@ class SSTB2BCalleeSession
114 113
 
115 114
  protected:
116 115
   void onSipRequest(const AmSipRequest& req);
117
-  void onSipReply(const AmSipReply& reply, int old_dlg_status,
118
-		  const string& trans_method);
116
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
119 117
   void onSendRequest(const string& method, const string& content_type,
120 118
 		     const string& body, string& hdrs, int flags, unsigned int cseq);
121 119
 
... ...
@@ -243,13 +243,13 @@ bool SWPrepaidSIPDialog::onOtherReply(const AmSipReply& reply)
243 243
         m_user_timer->invoke("setTimer", di_args, ret);
244 244
       }
245 245
     }
246
-    else if(reply.code == 487 && dlg.getStatus() == AmSipDialog::Pending) {
246
+    else if(reply.code == 487 && dlg.getStatus() < AmSipDialog::Connected) {
247 247
       DBG("Canceling leg A on 487 from B");
248 248
       dlg.reply(m_localreq, 487, "Call terminated");
249 249
       setStopped();
250 250
       ret = true;
251 251
     }
252
-    else if (reply.code >= 300 && dlg.getStatus() == AmSipDialog::Connected) {
252
+    else if (dlg.getStatus() == AmSipDialog::Connected) {
253 253
       DBG("Callee final error in connected state with code %d\n",reply.code);
254 254
       terminateLeg();
255 255
     }
... ...
@@ -281,11 +281,8 @@ void SWPrepaidSIPDialog::onBye(const AmSipRequest& req)
281 281
 
282 282
 void SWPrepaidSIPDialog::onCancel()
283 283
 {
284
-  if(dlg.getStatus() == AmSipDialog::Pending) {
285
-    DBG("Wait for leg B to terminate");
286
-  }
287
-  else {
288
-    DBG("Canceling leg A on CANCEL since dialog is not pending");
284
+  if(dlg.getStatus() == AmSipDialog::Cancelling) {
285
+    terminateLeg();
289 286
     dlg.reply(m_localreq, 487, "Call terminated");
290 287
     setStopped();
291 288
   }
... ...
@@ -173,16 +173,16 @@ void WebConferenceDialog::onSessionStart(const AmSipReply& rep) {
173 173
   connectConference(dlg.user);
174 174
 }
175 175
 
176
-void WebConferenceDialog::onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method)
176
+void WebConferenceDialog::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
177 177
 {
178 178
   //int status = dlg.getStatus();
179 179
 
180
-  AmSession::onSipReply(reply,old_dlg_status,trans_method);
180
+  AmSession::onSipReply(reply,old_dlg_status);
181 181
 
182 182
   DBG("reply: %u %s, old_dlg_status = %s, status = %s\n",
183 183
       reply.code, reply.reason.c_str(),
184
-      AmSipDialog::status2str[old_dlg_status],
185
-      AmSipDialog::status2str[dlg.getStatus()]);
184
+      dlgStatusStr(old_dlg_status),
185
+      dlg.getStatusStr());
186 186
 
187 187
   if ((old_dlg_status < AmSipDialog::Connected) && 
188 188
       (dlg.getStatus() == AmSipDialog::Disconnected)) {
... ...
@@ -196,17 +196,22 @@ void WebConferenceDialog::onSipReply(const AmSipReply& reply, int old_dlg_status
196 196
     ConferenceRoomParticipant::ParticipantStatus rep_st = 
197 197
       ConferenceRoomParticipant::Connecting;
198 198
     switch (dlg.getStatus()) {
199
-    case AmSipDialog::Pending: {
199
+    case AmSipDialog::Trying:
200
+    case AmSipDialog::Proceeding:
201
+    case AmSipDialog::Early:
202
+      {
200 203
       rep_st = ConferenceRoomParticipant::Connecting;
201
-      if (reply.code == 180) 
204
+      if (reply.code == 180 || reply.code == 183) 
202 205
 	rep_st  = ConferenceRoomParticipant::Ringing;
203 206
     } break;
204 207
     case AmSipDialog::Connected: 
205 208
       rep_st = ConferenceRoomParticipant::Connected; break;
209
+    case AmSipDialog::Cancelling:
206 210
     case AmSipDialog::Disconnecting: 
207 211
       rep_st = ConferenceRoomParticipant::Disconnecting; break;    
208 212
     case AmSipDialog::Disconnected: 
209
-      rep_st = ConferenceRoomParticipant::Finished; break;    
213
+      rep_st = ConferenceRoomParticipant::Finished; break;
214
+    default:break;
210 215
     }
211 216
     DBG("is dialout: updateing status\n");
212 217
     factory->updateStatus(dlg.user, getLocalTag(), 
... ...
@@ -94,7 +94,7 @@ public:
94 94
   ~WebConferenceDialog();
95 95
 
96 96
   void process(AmEvent* ev);
97
-  void onSipReply(const AmSipReply& reply, int old_dlg_status, const string& trans_method);
97
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
98 98
   void onSessionStart(const AmSipRequest& req);
99 99
   void onSessionStart(const AmSipReply& rep);
100 100
   void onEarlySessionStart(const AmSipReply& rep);
... ...
@@ -354,9 +354,8 @@ void AmB2ABCalleeSession::onSessionStart(const AmSipReply& rep) {
354 354
 }
355 355
 
356 356
 void AmB2ABCalleeSession::onSipReply(const AmSipReply& rep,
357
-				     AmSipDialog::Status old_dlg_status,
358
-				     const string& trans_method) {
359
-  AmB2ABSession::onSipReply(rep, old_dlg_status, trans_method);
357
+				     AmSipDialog::Status old_dlg_status) {
358
+  AmB2ABSession::onSipReply(rep, old_dlg_status);
360 359
   AmSipDialog::Status status = dlg.getStatus();
361 360
  
362 361
   if ((old_dlg_status == AmSipDialog::Trying) ||
... ...
@@ -247,8 +247,7 @@ class AmB2ABCalleeSession: public AmB2ABSession
247 247
 
248 248
   void onEarlySessionStart(const AmSipReply& rep);
249 249
   void onSessionStart(const AmSipReply& rep);
250
-  void onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status,
251
-		  const string& trans_method);
250
+  void onSipReply(const AmSipReply& rep, AmSipDialog::Status old_dlg_status);
252 251
 
253 252
  protected:
254 253
   void onB2ABEvent(B2ABEvent* ev);
... ...
@@ -188,14 +188,13 @@ void AmB2BSession::onSipRequest(const AmSipRequest& req)
188 188
 }
189 189
 
190 190
 void AmB2BSession::onSipReply(const AmSipReply& reply,
191
-			      AmSipDialog::Status old_dlg_status,
192
-			      const string& trans_method)
191
+			      AmSipDialog::Status old_dlg_status)
193 192
 {
194 193
   TransMap::iterator t = relayed_req.find(reply.cseq);
195 194
   bool fwd = (t != relayed_req.end()) && (reply.code != 100);
196 195
 
197 196
   DBG("onSipReply: %s -> %i %s (fwd=%s)\n",
198
-      trans_method.c_str(), reply.code,reply.reason.c_str(),fwd?"true":"false");
197
+      reply.cseq_method.c_str(), reply.code,reply.reason.c_str(),fwd?"true":"false");
199 198
   DBG("onSipReply: content-type = %s\n",reply.content_type.c_str());
200 199
   if(fwd) {
201 200
     updateRefreshMethod(reply.hdrs);
... ...
@@ -212,8 +211,8 @@ void AmB2BSession::onSipReply(const AmSipReply& reply,
212 211
 	relayed_req.erase(t);
213 212
     }
214 213
   } else {
215
-    AmSession::onSipReply(reply, old_dlg_status, trans_method);
216
-    relayEvent(new B2BSipReplyEvent(reply, false, trans_method));
214
+    AmSession::onSipReply(reply, old_dlg_status);
215
+    relayEvent(new B2BSipReplyEvent(reply, false, reply.cseq_method));
217 216
   }
218 217
 }
219 218
 
... ...
@@ -531,12 +530,10 @@ void AmB2BCallerSession::relayEvent(AmEvent* ev)
531 530
   AmB2BSession::relayEvent(ev);
532 531
 }
533 532
 
534
-void AmB2BCallerSession::onSessionStart(/*const AmSipRequest& req*/)
533
+void AmB2BCallerSession::onInvite(const AmSipRequest& req)
535 534
 {
536
-  //TODO:
537
-  //invite_req = req;
538
-  //AmB2BSession::onSessionStart(req);
539
-  assert(0);
535
+  invite_req = req;
536
+  AmB2BSession::onInvite(req);
540 537
 }
541 538
 
542 539
 void AmB2BCallerSession::connectCallee(const string& remote_party,
... ...
@@ -175,8 +175,7 @@ class AmB2BSession: public AmSession
175 175
 
176 176
   /** @see AmSession */
177 177
   void onSipRequest(const AmSipRequest& req);
178
-  void onSipReply(const AmSipReply& reply,
179
-		  AmSipDialog::Status old_dlg_status, const string& trans_method);
178
+  void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
180 179
   void onInvite2xx(const AmSipReply& reply);
181 180
 
182 181
   void onSessionTimeout();
... ...
@@ -259,7 +258,7 @@ class AmB2BCallerSession: public AmB2BSession
259 258
   const AmSipRequest& getOriginalRequest() { return invite_req; }
260 259
 
261 260
   // @see AmSession
262
-  void onSessionStart(/*const AmSipRequest& req*/);
261
+  void onInvite(const AmSipRequest& req);
263 262
 
264 263
   // @see AmB2BSession
265 264
   void terminateLeg();
... ...
@@ -233,6 +233,15 @@ int AmPrecodedFile::getDynPayload(const string& name, int rate, int encoding_par
233 233
   return -1;
234 234
 }
235 235
 
236
+
237
+void AmPrecodedFile::getPayloads(vector<SdpPayload>& pl_vec)
238
+{
239
+  for(std::map<int,precoded_payload_t>::iterator pl_it = payloads.begin();
240
+      pl_it != payloads.end(); ++pl_it) {
241
+    pl_vec.push_back(SdpPayload(pl_it->first, pl_it->second.name, pl_it->second.sample_rate, 0));
242
+  }
243
+}
244
+
236 245
 AmPrecodedFileInstance* AmPrecodedFile::getFileInstance(int payload_id, 
237 246
 							const vector<SdpPayload*>&  m_payloads) {
238 247
   std::map<int,precoded_payload_t>::iterator it=payloads.find(payload_id);
... ...
@@ -113,6 +113,8 @@ class AmPrecodedFile
113 113
   amci_payload_t*  payload(int payload_id);
114 114
   int getDynPayload(const string& name, int rate, int encoding_param);
115 115
 
116
+  void getPayloads(vector<SdpPayload>& pl_vec);
117
+
116 118
   AmPrecodedFileInstance* getFileInstance(int payload_id, const vector<SdpPayload*>&  m_payloads);
117 119
 };
118 120
 
... ...
@@ -148,7 +148,7 @@ int AmSdp::parse(const char* _sdp_msg)
148 148
   return ret;
149 149
 }
150 150
 
151
-void AmSdp::print(string& body)
151
+void AmSdp::print(string& body) const
152 152
 {
153 153
   string out_buf =
154 154
       "v="+int2str(version)+"\r\n"
... ...
@@ -157,13 +157,13 @@ void AmSdp::print(string& body)
157 157
       "c=IN IP4 "+conn.address+"\r\n"
158 158
       "t=0 0\r\n";
159 159
 
160
-  for(std::vector<SdpMedia>::iterator media_it = media.begin();
160
+  for(std::vector<SdpMedia>::const_iterator media_it = media.begin();
161 161
       media_it != media.end(); media_it++) {
162 162
       
163 163
       out_buf += "m=" + media_t_2_str(media_it->type) + " " + int2str(media_it->port) + " " + transport_p_2_str(media_it->transport);
164 164
 
165 165
       string options;
166
-      for(std::vector<SdpPayload>::iterator pl_it = media_it->payloads.begin();
166
+      for(std::vector<SdpPayload>::const_iterator pl_it = media_it->payloads.begin();
167 167
 	  pl_it != media_it->payloads.end(); pl_it++) {
168 168
 
169 169
 	  out_buf += " " + int2str(pl_it->payload_type);
... ...
@@ -174,7 +174,7 @@ public:
174 174
    * Prints the current SDP structure
175 175
    * into a proper SDP message.
176 176
    */
177
-  void print(string& body);
177
+  void print(string& body) const;
178 178
 
179 179
   /**
180 180
    * Test if the SDP message advertises 
... ...
@@ -708,9 +708,9 @@ void AmSession::onSipRequest(const AmSipRequest& req)
708 708
 }
709 709
 
710 710
 void AmSession::onSipReply(const AmSipReply& reply,
711
-			   AmSipDialog::Status old_dlg_status, const string& trans_method)
711
+			   AmSipDialog::Status old_dlg_status)
712 712
 {
713
-  CALL_EVENT_H(onSipReply, reply, old_dlg_status, trans_method);
713
+  CALL_EVENT_H(onSipReply, reply, old_dlg_status);
714 714
 
715 715
   updateRefreshMethod(reply.hdrs);
716 716
 
... ...
@@ -489,8 +489,7 @@ public:
489 489
   virtual void onSipRequest(const AmSipRequest& req);
490 490
 
491 491
   /** Entry point for SIP Replies   */
492
-  virtual void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status,
493
-			      const string& trans_method);
492
+  virtual void onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status);
494 493
 
495 494
   /** 2xx reply has been received for an INVITE transaction */
496 495
   virtual void onInvite2xx(const AmSipReply& reply);
... ...
@@ -43,8 +43,7 @@ bool AmSessionEventHandler::onSipRequest(const AmSipRequest&)
43 43
   return false;
44 44
 }
45 45
 
46
-bool AmSessionEventHandler::onSipReply(const AmSipReply& reply, int old_dlg_status,
47
-				       const string& trans_method)
46
+bool AmSessionEventHandler::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
48 47
 {
49 48
   return false;
50 49
 }
... ...
@@ -30,6 +30,7 @@
30 30
 #include "AmArg.h"
31 31
 #include "AmSipMsg.h"
32 32
 #include "AmSipEvent.h"
33
+#include "AmSipDialog.h"
33 34
 #include <string>
34 35
 using std::string;
35 36
 
... ...
@@ -66,8 +67,7 @@ public:
66 67
   virtual bool process(AmEvent*);
67 68
 
68 69
   virtual bool onSipRequest(const AmSipRequest&);
69
-  virtual bool onSipReply(const AmSipReply&, int old_dlg_status,
70
-			  const string& trans_method);
70
+  virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status);
71 71
   virtual bool onSipReqTimeout(const AmSipRequest &);
72 72
   virtual bool onSipRplTimeout(const AmSipRequest &, const AmSipReply &);
73 73
 
... ...
@@ -311,30 +311,25 @@ int AmSipDialog::onTxSdp(const string& body)
311 311
   return 0;
312 312
 }
313 313
 
314
-int AmSipDialog::triggerOfferAnswer(string& content_type, string& body)
314
+int AmSipDialog::getSdpBody(string& sdp_body)
315 315
 {
316
-  switch(status){
317
-  case Connected:
318
-  case Early:
319 316
     switch(oa_state){
320 317
     case OA_None:
321 318
     case OA_Completed:
322 319
       if(hdl->getSdpOffer(sdp_local)){
323
-	sdp_local.print(body);
324
-	content_type = "application/sdp";//FIXME
320
+	sdp_local.print(sdp_body);
325 321
       }
326 322
       else {
327
-	DBG("No SDP Offer to include in the reply.\n");
323
+	DBG("No SDP Offer.\n");
328 324
 	return -1;
329 325
       }
330 326
       break;
331 327
     case OA_OfferRecved:
332 328
       if(hdl->getSdpAnswer(sdp_remote,sdp_local)){
333
-	sdp_local.print(body);
334
-	content_type = "application/sdp";//FIXME
329
+	sdp_local.print(sdp_body);
335 330
       }
336 331
       else {
337
-	DBG("No SDP Answer to include in the reply.\n");
332
+	DBG("No SDP Answer.\n");
338 333
 	return -1;
339 334
       }
340 335
       break;
... ...
@@ -342,9 +337,29 @@ int AmSipDialog::triggerOfferAnswer(string& content_type, string& body)
342 337
     default: 
343 338
       break;
344 339
     }
340
+
341
+    return 0;
342
+}
343
+
344
+int AmSipDialog::triggerOfferAnswer(string& content_type, string& body)
345
+{
346
+  switch(status){
347
+
348
+  case Early:
349
+    if(content_type != "application/sdp"){ // FIXME
350
+      break;
351
+    }
352
+    return getSdpBody(body);
353
+
354
+  case Connected:
355
+    if(getSdpBody(body)){
356
+      return -1;
357
+    }
358
+
359
+    content_type = "application/sdp"; // FIXME
345 360
     break;
346 361
     
347
-  default: 
362
+  default:
348 363
     break;
349 364
   }
350 365
 
... ...
@@ -607,7 +622,7 @@ void AmSipDialog::onRxReply(const AmSipReply& reply)
607 622
     }
608 623
   }
609 624
 
610
-  hdl->onSipReply(reply, old_dlg_status, trans_method);
625
+  hdl->onSipReply(reply, old_dlg_status);
611 626
 }
612 627
 
613 628
 void AmSipDialog::uasTimeout(AmSipTimeoutEvent* to_ev)
... ...
@@ -253,7 +253,8 @@ private:
253 253
   int onRxSdp(const string& body, const char** err_txt);
254 254
   int onTxSdp(const string& body);
255 255
 
256
-  int  triggerOfferAnswer(string& content_type, string& body);
256
+  int getSdpBody(string& sdp_body);
257
+  int triggerOfferAnswer(string& content_type, string& body);
257 258
 };
258 259
 
259 260
 const char* dlgStatusStr(AmSipDialog::Status st);
... ...
@@ -274,8 +275,7 @@ class AmSipDialogEventHandler
274 275
 
275 276
   /** Hook called when a reply has been received */
276 277
   virtual void onSipReply(const AmSipReply& reply, 
277
-			  AmSipDialog::Status old_dlg_status,
278
-			  const string& trans_meth)=0;
278
+			  AmSipDialog::Status old_dlg_status)=0;
279 279
 
280 280
   /** Hook called before a request is sent */
281 281
   virtual void onSendRequest(const string& method,
... ...
@@ -77,8 +77,7 @@ bool SessionTimer::onSipRequest(const AmSipRequest& req)
77 77
   return false;
78 78
 }
79 79
 
80
-bool SessionTimer::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status,
81
-			      const string& trans_method)
80
+bool SessionTimer::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
82 81
 {
83 82
   updateTimer(s,reply);
84 83
   return false;
... ...
@@ -141,8 +141,7 @@ class SessionTimer: public AmSessionEventHandler
141 141
   virtual bool process(AmEvent*);
142 142
 
143 143
   virtual bool onSipRequest(const AmSipRequest&);
144
-  virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status,
145
-			  const string& trans_method);
144
+  virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status);
146 145
 
147 146
   virtual bool onSendRequest(const string& method, 
148 147
 			     const string& content_type,
... ...
@@ -124,7 +124,7 @@ bool UACAuth::onSipRequest(const AmSipRequest& req)
124 124
   return false;
125 125
 }
126 126
 
127
-bool UACAuth::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status, const string& trans_method)
127
+bool UACAuth::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
128 128
 {
129 129
   bool processed = false;
130 130
   if (reply.code==407 || reply.code==401) {
... ...
@@ -138,7 +138,7 @@ class UACAuth : public AmSessionEventHandler
138 138
   virtual bool process(AmEvent*);
139 139
   virtual bool onSipEvent(AmSipEvent*);
140 140
   virtual bool onSipRequest(const AmSipRequest&);
141
-  virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status, const string& trans_method);
141
+  virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status);
142 142
 	
143 143
   virtual bool onSendRequest(const string& method, 
144 144
 			     const string& content_type,