[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 10:06:31 CDT 2010
branch "master" has been updated
via 33cb866433a631c952b3c17a668da144fc4a7705 (commit)
from b1894c18bc03ee869333c5a77cecaa2f0da3ddcf (commit)
Summary of changes:
slice | 2 +-
src/PJSipSessionModule.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 62 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 33cb866433a631c952b3c17a668da144fc4a7705
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Aug 25 10:06:47 2010 -0500
Create INVITE session UAS on reception of INVITE.
Also now will send a 100 Trying message.
diff --git a/slice b/slice
index dcb271b..d6b2777 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit dcb271baaca90fa89ed6b7d4846ea458fb303943
+Subproject commit d6b2777545b3b8eae7c5dc9b40a1ca3ff9e26a43
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index de09e0f..0ca0ff8 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -54,8 +54,54 @@ static void handle_new_invite(pjsip_rx_data *rdata)
//sending a 100 trying, finding the remote endpoint
//to call, and placing a call to it.
+ //XXX All failure cases need to have cleanup and
+ //returing added in addition to printing a message
+ //as they do now.
+
//XXX Put caller identification code in here!
+ //XXX According to pjsip docs, we should call
+ //pjsip_inv_verify_request to be sure we can
+ //handle the request. For now, just plunge forward.
+
+ pjsip_dialog *dlg;
+ //XXX The NULL parameter should be replaced with
+ //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);
+
+ if (status != PJ_SUCCESS)
+ {
+ std::cerr << "[WARNING] Unable to create UAS dialog on incoming INVITE" << std::endl;
+ }
+
+ //XXX The sdp argument is NULL for now, but can be changed if we
+ //know what has been configured for this particular caller.
+
+ pjsip_inv_session *inv_session;
+ status = pjsip_inv_create_uas(dlg, rdata, NULL, 0, &inv_session);
+
+ if (status != PJ_SUCCESS)
+ {
+ std::cerr << "[WARNING] Unable to create INVITE session" << std::endl;
+ }
+
+ pjsip_tx_data *tdata;
+ status = pjsip_inv_initial_answer(inv_session, rdata, 100, NULL, NULL, &tdata);
+
+ if (status != PJ_SUCCESS)
+ {
+ std::cerr << "[WARNING] Failed to create 100 Trying response" << std::endl;
+ }
+
+ status = pjsip_inv_send_msg(inv_session, tdata);
+
+ if (status != PJ_SUCCESS)
+ {
+ std::cerr << "[WARNING] Failed to send 100 Trying response" << std::endl;
+ }
+
SipChannelServiceDataModel &dataModel = SipChannelServiceDataModel::getInstance();
boost::shared_ptr<SipEndpointFactory> factory = dataModel.getEndpointFactory();
//XXX Hardcoded "Butt" is bad for a lot of reasons,
@@ -78,11 +124,11 @@ static void handle_new_invite(pjsip_rx_data *rdata)
{
endpoints = locator->lookup(destination);
}
- catch (DestinationNotFoundException destEx)
+ catch (DestinationNotFoundException &destEx)
{
std::cerr << "[WARNING] Could not find destination " << destEx.destination << std::endl;
}
- catch (InvalidParamsException invalEx)
+ catch (InvalidParamsException &invalEx)
{
std::cerr << "[WARNING] Invalid parameters in endpoint lookup. " << std::endl;
}
@@ -263,6 +309,12 @@ static pjsip_redirect_op invOnRedirected(pjsip_inv_session *inv, const pjsip_uri
return PJSIP_REDIRECT_REJECT;
}
+static pjsip_dialog *uaOnDialogForked(pjsip_dialog *first_set, pjsip_rx_data *rdata)
+{
+ //stub
+ return NULL;
+}
+
PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
{
// XXX Set the module name here. It's a pain in the neck
@@ -280,6 +332,12 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
mModule.on_tx_response = sessionOnTransmitResponse;
mModule.on_tsx_state = sessionOnTransactionStateChange;
+ if (pjsip_ua_instance()->id == -1)
+ {
+ pj_bzero(&mUaParam, sizeof(&mUaParam));
+ mUaParam.on_dlg_forked = uaOnDialogForked;
+ }
+
if (pjsip_inv_usage_instance()->id == -1)
{
pj_bzero(&mInvCallback, sizeof(&mInvCallback));
@@ -295,6 +353,7 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
PJSipManager *manager = PJSipManager::getInstance();
pjsip_endpoint *endpt = manager->getEndpoint();
+ pjsip_ua_init_module(endpt, &mUaParam);
pjsip_inv_usage_init(endpt, &mInvCallback);
manager->registerModule(&mModule);
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list