Browse code

b/f: conference dialout.

Raphael Coeffic authored on 26/10/2011 15:03:11
Showing 1 changed files
... ...
@@ -406,8 +406,6 @@ void ConferenceDialog::onStart() {
406 406
 
407 407
 void ConferenceDialog::onInvite(const AmSipRequest& req)
408 408
 {
409
-  AmSession::onInvite(req);
410
-  
411 409
   if(dlg.getStatus() == AmSipDialog::Connected)
412 410
     return;
413 411
 
... ...
@@ -487,11 +485,22 @@ void ConferenceDialog::onInvite(const AmSipRequest& req)
487 485
 
488 486
   DBG("Using LonelyUserFile <%s>\n",
489 487
       ConferenceFactory::LonelyUserFile.c_str());
488
+
489
+  AmSession::onInvite(req);  
490 490
 }
491 491
 
492 492
 void ConferenceDialog::onSessionStart()
493 493
 {
494 494
   setupAudio();
495
+
496
+  if(dialedout) {
497
+    // send connect event
498
+    AmSessionContainer::instance()
499
+      ->postEvent(dialout_channel->getConfID(),
500
+		  new DialoutConfEvent(DoConfConnect,
501
+				       dialout_channel->getConfID()));
502
+  }
503
+
495 504
   AmSession::onSessionStart();
496 505
 }
497 506
 
... ...
@@ -890,106 +899,63 @@ void ConferenceDialog::onSipRequest(const AmSipRequest& req)
890 899
 
891 900
 void ConferenceDialog::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status)
892 901
 {
893
-  //int status = dlg.getStatus();
894 902
   AmSession::onSipReply(reply, old_dlg_status);
895 903
 
896 904
   DBG("ConferenceDialog::onSipReply: code = %i, reason = %s\n, status = %i\n",
897 905
       reply.code,reply.reason.c_str(),dlg.getStatus());
898 906
     
899
-  if(!dialedout && 
900
-     !transfer_req.get())
907
+  if(!dialedout /*&& !transfer_req.get()*/)
901 908
     return;
902 909
 
903
-  /*
904
-  if(status < AmSipDialog::Connected){
910
+  if((old_dlg_status < AmSipDialog::Connected) &&
911
+     (reply.cseq_method == SIP_METH_INVITE)){
905 912
 
906 913
     switch(dlg.getStatus()){
907 914
 
908
-    case AmSipDialog::Connected:
909
-
910
-      // connected!
911
-      try {
912
-
913
-	acceptAudio(reply.body,reply.hdrs);
914
-
915
-	if(getDetached() && !getStopped()){
916
-		    
917
-	  setupAudio();
918
-		    
919
-	  if(getInput() || getOutput())
920
-	    AmMediaProcessor::instance()->addSession(this,
921
-						     getCallgroup()); 
922
-	  else { 
923
-	    ERROR("missing audio input and/or ouput.\n");
924
-	    return;
925
-	  }
926
-
927
-	  if(!transfer_req.get()){
928
-
929
-	    // send connect event
930
-	    AmSessionContainer::instance()
931
-	      ->postEvent(dialout_channel->getConfID(),
932
-			  new DialoutConfEvent(DoConfConnect,
933
-					       dialout_channel->getConfID()));
934
-	  }
935
-	  else {
936
-	    dlg.reply(*(transfer_req.get()),202,"Accepted");
937
-	    transfer_req.reset(0);
938
-	    connectMainChannel();
939
-	  }
940
-	} 
941
-	
942
-      }
943
-      catch(const AmSession::Exception& e){
944
-	ERROR("%i %s\n",e.code,e.reason.c_str());
945
-	dlg.bye();
946
-	setStopped();
947
-      }
948
-      break;
949
-
950
-    case AmSipDialog::Pending:
915
+    case AmSipDialog::Proceeding:
916
+    case AmSipDialog::Early:
951 917
 
952 918
       switch(reply.code){
953 919
       case 180:
920
+      case 183: break;//TODO: remote ring tone.
954 921
 
955
-	// send ringing event
956
-	AmSessionContainer::instance()
957
-	  ->postEvent(dialout_channel->getConfID(),
958
-		      new DialoutConfEvent(DoConfRinging,
959
-					   dialout_channel->getConfID()));
922
+	if(dialout_channel.get()){
923
+	  // send ringing event
924
+	  AmSessionContainer::instance()
925
+	    ->postEvent(dialout_channel->getConfID(),
926
+			new DialoutConfEvent(DoConfRinging,
927
+					     dialout_channel->getConfID()));
928
+	}
960 929
 		
961 930
 	break;
962
-      case 183: break;//TODO: remote ring tone.
963 931
       default:  break;// continue waiting.
964 932
       }
965 933
       break;
966 934
 
967 935
     case AmSipDialog::Disconnected:
968 936
 
969
-      if(!transfer_req.get()){
970
-
937
+      // if(!transfer_req.get()){
938
+      
939
+      if(dialout_channel.get()){
971 940
 	disconnectDialout();
972
-	//switch(reply.code){
973
-	//default:
974
-	    
975 941
 	AmSessionContainer::instance()
976 942
 	  ->postEvent(dialout_channel->getConfID(),
977 943
 		      new DialoutConfEvent(DoConfError,
978 944
 					   dialout_channel->getConfID()));
979
-	//}
980
-      }
981
-      else {
982
-		
983
-	dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
984
-	transfer_req.reset(0);
985
-	setStopped();
986 945
       }
946
+      setStopped();
947
+
948
+      // }
949
+      // else {
950
+      // 	dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
951
+      // 	transfer_req.reset(0);
952
+      // 	setStopped();
953
+      // }
987 954
       break;
988 955
 
989 956
     default: break;
990 957
     }
991 958
   }
992
-  */
993 959
 }
994 960
 
995 961
 #ifdef WITH_SAS_TTS