[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
Wed Aug 25 19:41:39 CDT 2010


branch "master" has been updated
       via  82d65922352574f503be385ce5139d5937b9fae9 (commit)
       via  9b651b635135ee58595e9357acba300d8d4eedc3 (commit)
       via  bcef007ca819c2ca55025ed76cc8e5c54c6e1fb1 (commit)
      from  9ab3a86daa7ccdbc052ad38718a2e77cb79b17d5 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   89 ++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 27 deletions(-)


- Log -----------------------------------------------------------------
commit 82d65922352574f503be385ce5139d5937b9fae9
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 19:41:13 2010 -0500

    Various changes in PJSipSessionModule; mostly comments addressing specific situations.
    
    There is a bit of confusion by me about how to get a SessionEndpointPtr correctly
    given the BaseEndpointPtr I put in the mod_data. Suggestions so far haven't compiled
    correctly, so I've just mapped out what needs to be done in each situation so that
    I can go about doing it correctly once I get past the initial hurdle.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 6408a74..e0742fd 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -1,6 +1,7 @@
 #include <Core/Endpoint/EndpointIf.h>
 #include <Core/Routing/RoutingIf.h>
 #include <Core/Bridging/BridgeServiceIf.h>
+#include <Session/SessionIf.h>
 
 #include "PJSipSessionModule.h"
 #include "SipChannelServiceDataModel.h"
@@ -16,6 +17,7 @@ namespace SipChannelService
 using namespace Hydra::Core::Routing::V1;
 using namespace Hydra::Core::Bridging::V1;
 using namespace Hydra::Core::Endpoint::V1;
+using namespace Hydra::Session::V1;
 
 static pj_status_t sessionLoad(pjsip_endpoint *endpt)
 {
@@ -69,7 +71,8 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	//An appropriate Contact header. Leaving it NULL makes
 	//PJSIP create the contact header for responses based
 	//on the To header of the incoming Invite.
-	pj_status_t status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg);
+	pjsip_module *module = pjsip_ua_instance();
+	pj_status_t status = pjsip_dlg_create_uas(module, rdata, NULL, &dlg);
 
 	if (status != PJ_SUCCESS)
 	{
@@ -134,12 +137,6 @@ static void handle_new_invite(pjsip_rx_data *rdata)
 	}
 	//Adding the SipEndpoint to the dialog's mod_data makes it easy to
 	//retrieve during signal callbacks.
-	PJSipManager *manager = dataModel.getPJSipManager();
-	pjsip_module *module = manager->getSessionModule();
-	if (module == NULL)
-	{
-		std::cerr << "[WARNING] Um, couldn't get the module from the PJSipManger??" << std::endl;
-	}
 	dlg->mod_data[module->id] = (void *)caller;
 	BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
 	BridgePrx bridge = bridgeFactory->createBridge(*caller, endpoints, 0);
@@ -166,11 +163,13 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 	{
 		if (dlg == NULL)
 		{
-			// Send a 481
+			// This is handled by pjsip. It will
+			// send back a 481 for us.
 		}
 		else
 		{
-			// Ending the call for realsies.
+			// We'll want to get the SipEndpoint,
+			// and call its terminated() callback.
 		}
 		break;
 	}
@@ -183,11 +182,14 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 	{
 		if (dlg == NULL)
 		{
-			// Send a 481
+			// This is handled by pjsip. It will
+			// send back a 481 for us.
 		}
 		else
 		{
-			// Let the other side know we changed our minds.
+			// Just like with a BYE, we'll get
+			// the endpoint and call its terminated()
+			// callback.
 		}
 		break;
 	}
@@ -199,7 +201,8 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 	}
 	case PJSIP_OTHER_METHOD:
 	{
-		//Potentially need to handle some SDP changes here on UPDATE/PRACK.
+		//Potentially need to handle some SDP changes here on UPDATE/PRACK,
+		//but those will likely hit our inv_callbacks instead.
 		//This is all for now. Later we'll have support for
 		//REFER and INFO. SUBSCRIBE, NOTIFY, REGISTER, and
 		//PUBLISH fall into other modules' responsibilities.
@@ -212,8 +215,19 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 static void handle_invite_response(pjsip_rx_data *rdata)
 {
 	int respCode = rdata->msg_info.msg->line.status.code;
+	//Commented because they are currently unused. They
+	//will be once the individual cases are mapped out.
+	//pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
+	//pjsip_module *module = pjsip_ua_instance();
+	//
 	//XXX There are a BUNCH of response codes we need
 	//to add code to handle.
+	
+	//Treat all 1XX messages we don't recognize the same as a 180
+	if (respCode > 100 && respCode < 200 && respCode != 183)
+	{
+		respCode = 180;
+	}
 	if (respCode == 100)
 	{
 		//Not sure if PJSIP even bothers passing these up
@@ -265,8 +279,10 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
 	}
 	case PJSIP_BYE_METHOD:
 	{
-		//We'll mostly not care about this response, except for
-		//the 401/407 of course.
+		//Giving it some thought, it seems like we really don't
+		//care what the response is here. The only response that
+		//actually warrants action is a 401/407, and that's taken
+		//care of for us.
 		break;
 	}
 	case PJSIP_CANCEL_METHOD:

commit 9b651b635135ee58595e9357acba300d8d4eedc3
Merge: bcef007 9ab3a86
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 18:56:46 2010 -0500

    Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/sip


commit bcef007ca819c2ca55025ed76cc8e5c54c6e1fb1
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Aug 25 16:29:46 2010 -0500

    Add skeleton for INVITE response handler.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 4ff431d..6408a74 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -211,19 +211,38 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
 
 static void handle_invite_response(pjsip_rx_data *rdata)
 {
-	//Let's see...(This will probably be in its own function)
-	//180: Tell the bridge to ring() the other side
-	//183: Tell the bridge to progress() the other side
-	//Other 1XX, treat like a 180, I guess.
-	//2XX: There had better be an SDP. Parse and give it
-	//to the media layer. Send an ACK. If necessary put
-	//an SDP answer in the ACK.
-	//3XX: Hm, good question. I suppose I should essentially
-	//treat this as a new incoming call to the URI in the
-	//Contact header. Also terminate the previous outgoing
-	//dialog.
-	//400-699: Unless it's a 401 or 407, that means to
-	//terminate the call.
+	int respCode = rdata->msg_info.msg->line.status.code;
+	//XXX There are a BUNCH of response codes we need
+	//to add code to handle.
+	if (respCode == 100)
+	{
+		//Not sure if PJSIP even bothers passing these up
+		std::cout << "[DEBUG] Got 100 response" << std::endl;
+	}
+	else if (respCode == 180)
+	{
+		//We'll need to get the caller endpoint and call his
+		//signalcallback's ring()
+		std::cout << "[DEBUG] Got 180 response" << std::endl;
+	}
+	else if (respCode == 183)
+	{
+		//We'll need to get the caller endpoint and call his
+		//signallcallback's progress()
+		std::cout << "[DEBUG] Got 183 response" << std::endl;
+	}
+	else if (respCode == 200)
+	{
+		//We'll need to get the caller endpoint and call his
+		//signalcallback's connected()
+		std::cout << "[DEBUG] Got 200 response" << std::endl;
+	}
+	else if (respCode >= 400)
+	{
+		//For now treat all failures the same. Call the
+		//caller's signalcallback's terminated()
+		std::cout << "[DEBUG] Got response " << respCode << "on outgoing INVITE" << std::endl;
+	}
 }
 
 static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list