[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Aug 26 12:27:51 CDT 2010


branch "master" has been updated
       via  547b8f12a97e5272edd4d25f064d4c8def3ec148 (commit)
      from  2d352e849f713c3b3853afc7c2d887dbba4add9c (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   21 ++++++++++++++++-----
 src/SipEndpoint.cpp        |    4 +++-
 2 files changed, 19 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 547b8f12a97e5272edd4d25f064d4c8def3ec148
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Aug 26 14:39:50 2010 -0300

    Add preliminary support for having the caller hang up.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 3968e8d..9faa465 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -143,6 +143,8 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	dlg->mod_data[module->id] = (void *)caller;
 	BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
 	BridgePrx bridge = bridgeFactory->createBridge((*caller)->getSessionEndpoint(), endpoints, 0);
+	Hydra::Session::V1::SignalCallbackPrx callback = Hydra::Session::V1::SignalCallbackPrx::checkedCast(bridge, "SignalCallback");
+	(*caller)->setSignalCallback(callback);
 }
 
 static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
@@ -215,7 +217,7 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 	return PJ_TRUE;
 }
 
-static void handle_invite_response(pjsip_rx_data *rdata, pjsip_dialog *dlg)
+static void handle_invite_response(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg)
 {
 	int respCode = rdata->msg_info.msg->line.status.code;
 	SipEndpointPtr *endpoint = (SipEndpointPtr*)dlg->mod_data[pjsip_ua_instance()->id];
@@ -255,7 +257,10 @@ static void handle_invite_response(pjsip_rx_data *rdata, pjsip_dialog *dlg)
 		//We'll need to get the caller endpoint and call his
 		//signalcallback's connected()
 		std::cout << "[DEBUG] Got 200 response" << std::endl;
-		(*endpoint)->getSignalCallback()->connected((*endpoint)->getSessionEndpoint()->id);
+		if (inv->state != PJSIP_INV_STATE_DISCONNECTED)
+		{
+		   (*endpoint)->getSignalCallback()->connected((*endpoint)->getSessionEndpoint()->id);
+		}
 	}
 	else if (respCode >= 400)
 	{
@@ -281,7 +286,6 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
 	{
 	case PJSIP_INVITE_METHOD:
 	{
-		handle_invite_response(rdata, dlg);
 		break;
 	}
 	case PJSIP_BYE_METHOD:
@@ -328,7 +332,14 @@ static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
 {
    if (inv->state == PJSIP_INV_STATE_DISCONNECTED)
    {
-      std::cout << "Invite session " << inv << " is disconnected" << std::endl;
+      SipEndpointPtr *endpoint = (SipEndpointPtr*)inv->dlg->mod_data[pjsip_ua_instance()->id];
+      if ((*endpoint)->getSignalCallback() != 0)
+      {
+	 Hydra::Session::V1::ResponseCodePtr response = new Hydra::Session::V1::ResponseCode();
+	 response->isdnCode = 42;
+	 (*endpoint)->getSignalCallback()->terminated((*endpoint)->getSessionEndpoint()->id, response);
+      }
+      (*endpoint)->destroy();
    }
 	//stub
 }
@@ -342,7 +353,7 @@ static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transacti
 {
    if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
    {
-	   handle_invite_response(e->body.tsx_state.src.rdata, inv->dlg);
+      handle_invite_response(inv, e->body.tsx_state.src.rdata, inv->dlg);
    }
 	//stub
 }
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 9c183c5..7b03048 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -76,10 +76,12 @@ public:
 
 	   return true;
 	}
-	void terminate(const Core::Endpoint::V1::EndpointIdPtr& caller, const Ice::Current&)
+	void terminate(const Core::Endpoint::V1::EndpointIdPtr&, const Ice::Current&)
 	{
 	   pjsip_tx_data *packet;
 
+	   mEndpoint->setSignalCallback(0);
+
 	   if ((pjsip_inv_end_session(mEndpoint->getInviteSession(), 503, NULL, &packet)) == PJ_SUCCESS)
 	   {
 	      pjsip_inv_send_msg(mEndpoint->getInviteSession(), packet);

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list