[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
Fri Sep 17 16:19:04 CDT 2010
branch "master" has been updated
via bfaedd83bd0142fdb5a3175249b278b8379ba8c0 (commit)
via 285ae40e7277e831fb54cad8bf521c6e59fadc39 (commit)
from 8af0138e46a6cdcfbf0f41ea740300f9e5d667da (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 188 +++++++++++++++++++-------------------------
src/PJSipSessionModule.h | 3 -
2 files changed, 81 insertions(+), 110 deletions(-)
- Log -----------------------------------------------------------------
commit bfaedd83bd0142fdb5a3175249b278b8379ba8c0
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Sep 17 15:31:03 2010 -0500
Add state replication on new INVITE handling.
Also removed a bunch of code that would never be called due to the way
the PJSIP INVITE session module works.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 0e0f0dd..3760f61 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -396,8 +396,6 @@ static void handle_new_invite(pjsip_rx_data *rdata)
PJSipSessionModInfo *session_mod_info = new PJSipSessionModInfo(inv_session);
session_mod_info->setSessionPtr(session);
- //Adding the SipEndpoint to the inv_session's mod_data makes it easy to
- //retrieve during signal callbacks.
inv_session->mod_data[module->id] = (void *)session_mod_info;
dlg->mod_data[module->id] = (void *)dlg_mod_info;
@@ -418,6 +416,12 @@ static void handle_new_invite(pjsip_rx_data *rdata)
pjsip_inv_answer(inv_session, 500, NULL, NULL, &tdata);
pjsip_inv_send_msg(inv_session, tdata);
}
+ // All the actual call routing is taken care of, so let's tell the state replicator
+ // what all we learned.
+ pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
+ PJSipTransactionModInfo *tsx_mod_info = new PJSipTransactionModInfo(tsx);
+ tsx->mod_data[module->id] = (void *)tsx_mod_info;
+ replicateState(dlg_mod_info, tsx_mod_info, session_mod_info);
}
static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
@@ -433,60 +437,16 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
}
else
{
- // Reinvite!
+ std::cerr << "[WARNING] on_rx_request called back in mid-dialog?" << std::endl;
}
break;
}
- case PJSIP_BYE_METHOD:
- {
- if (dlg == NULL)
- {
- // This is handled by pjsip. It will
- // send back a 481 for us.
- }
- else
- {
- // We'll want to get the SipEndpoint,
- // and call its terminated() callback.
- }
- break;
- }
- case PJSIP_ACK_METHOD:
- {
- //Perhaps will need to handle an SDP answer.
- break;
- }
- case PJSIP_CANCEL_METHOD:
- {
- if (dlg == NULL)
- {
- // This is handled by pjsip. It will
- // send back a 481 for us.
- }
- else
- {
- // Just like with a BYE, we'll get
- // the endpoint and call its terminated()
- // callback.
- }
- break;
- }
- case PJSIP_REGISTER_METHOD:
- case PJSIP_OPTIONS_METHOD:
- {
- //Not for us to handle.
- return PJ_FALSE;
- }
- case PJSIP_OTHER_METHOD:
+ default:
{
- //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.
return PJ_FALSE;
}
}
+
return PJ_TRUE;
}
commit 285ae40e7277e831fb54cad8bf521c6e59fadc39
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Sep 17 14:34:27 2010 -0500
Add state replication code into transaction state change code.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index cf52b6e..0e0f0dd 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -216,6 +216,58 @@ private:
SipSessionPtr mSession;
};
+static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo *tsxInfo,
+ PJSipSessionModInfo *sessionInfo)
+{
+ SipStateItemSeq setItems;
+ SipStateItemSeq removeItems;
+ if (dlgInfo)
+ {
+ if (dlgInfo->mNeedsReplication == true)
+ {
+ setItems.push_back(dlgInfo->mDialogState);
+ dlgInfo->mNeedsReplication = false;
+ }
+ else if (dlgInfo->mNeedsRemoval == true)
+ {
+ removeItems.push_back(dlgInfo->mDialogState);
+ }
+ }
+ if (tsxInfo)
+ {
+ if (tsxInfo->mNeedsReplication == true)
+ {
+ setItems.push_back(tsxInfo->mTransactionState);
+ tsxInfo->mNeedsReplication = false;
+ }
+ else if (tsxInfo->mNeedsRemoval == true)
+ {
+ removeItems.push_back(tsxInfo->mTransactionState);
+ }
+ }
+ if (sessionInfo)
+ {
+ if (sessionInfo->mNeedsReplication == true)
+ {
+ setItems.push_back(sessionInfo->mSessionState);
+ sessionInfo->mNeedsReplication = false;
+ }
+ else if (sessionInfo->mNeedsRemoval == true)
+ {
+ removeItems.push_back(sessionInfo->mSessionState);
+ }
+ }
+ SipStateReplicatorPrx replicator = SipChannelServiceDataModel::getInstance().getStateReplicator();
+ if (setItems.size() != 0)
+ {
+ replicator->setState(setItems);
+ }
+ if (removeItems.size() != 0)
+ {
+ replicator->removeState(removeItems);
+ }
+}
+
static pj_status_t sessionLoad(pjsip_endpoint *endpt)
{
//stub
@@ -556,6 +608,12 @@ static void sessionOnTransactionStateChange(pjsip_transaction *tsx, pjsip_event
static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
{
+ if (inv->state == PJSIP_INV_STATE_EARLY || inv->state == PJSIP_INV_STATE_CONNECTING &&
+ event->type == PJSIP_EVENT_RX_MSG)
+ {
+ //Received a 1XX or 2XX message in response to our initial outgoing INVITE.
+ handle_invite_response(inv, event->body.tsx_state.src.rdata, inv->dlg);
+ }
if (inv->state == PJSIP_INV_STATE_DISCONNECTED)
{
PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[pjsip_ua_instance()->id];
@@ -598,10 +656,6 @@ static void invOnNewSession(pjsip_inv_session *inv, pjsip_event *event)
static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
- if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
- {
- handle_invite_response(inv, e->body.tsx_state.src.rdata, inv->dlg);
- }
//This will be our key point for updating transaction state.
//This function will not be called until after a module has registered
//itself as the transaction user, so this won't be called on the initial
@@ -619,10 +673,22 @@ static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transacti
//and session changes.
pjsip_module *module = pjsip_ua_instance();
- PJSipTransactionModInfo *tsx_mod_data = static_cast<PJSipTransactionModInfo *> (tsx->mod_data[module->id]);
- tsx_mod_data->updateTransactionState(tsx);
+ PJSipTransactionModInfo *tsx_mod_info = static_cast<PJSipTransactionModInfo *> (tsx->mod_data[module->id]);
+ tsx_mod_info->updateTransactionState(tsx);
if (e->type == PJSIP_EVENT_TX_MSG)
{
+ pjsip_dialog *dlg = pjsip_tsx_get_dlg(tsx);
+ PJSipDialogModInfo *dlg_mod_info = NULL;
+ if (dlg)
+ {
+ dlg_mod_info = static_cast<PJSipDialogModInfo*>(dlg->mod_data[module->id]);
+ }
+ PJSipSessionModInfo *session_mod_info = static_cast<PJSipSessionModInfo*>(inv->mod_data[module->id]);
+ replicateState(dlg_mod_info, tsx_mod_info, session_mod_info);
+ }
+ else if (e->type == PJSIP_EVENT_TIMER)
+ {
+ replicateState(NULL, tsx_mod_info, NULL);
}
}
@@ -800,58 +866,6 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
pjsip_endpt_register_module(endpt, &mModule);
}
-void PJSipSessionModule::replicateState(PJSipDialogModInfo *dlgInfo,
- PJSipTransactionModInfo *tsxInfo, PJSipSessionModInfo *sessionInfo)
-{
- SipStateItemSeq setItems;
- SipStateItemSeq removeItems;
- if (dlgInfo)
- {
- if (dlgInfo->mNeedsReplication == true)
- {
- setItems.push_back(dlgInfo->mDialogState);
- dlgInfo->mNeedsReplication = false;
- }
- else if (dlgInfo->mNeedsRemoval == true)
- {
- removeItems.push_back(dlgInfo->mDialogState);
- }
- }
- if (tsxInfo)
- {
- if (tsxInfo->mNeedsReplication == true)
- {
- setItems.push_back(tsxInfo->mTransactionState);
- tsxInfo->mNeedsReplication = false;
- }
- else if (tsxInfo->mNeedsRemoval == true)
- {
- removeItems.push_back(tsxInfo->mTransactionState);
- }
- }
- if (sessionInfo)
- {
- if (sessionInfo->mNeedsReplication == true)
- {
- setItems.push_back(sessionInfo->mSessionState);
- sessionInfo->mNeedsReplication = false;
- }
- else if (sessionInfo->mNeedsRemoval == true)
- {
- removeItems.push_back(sessionInfo->mSessionState);
- }
- }
- SipStateReplicatorPrx replicator = SipChannelServiceDataModel::getInstance().getStateReplicator();
- if (setItems.size() != 0)
- {
- replicator->setState(setItems);
- }
- if (removeItems.size() != 0)
- {
- replicator->removeState(removeItems);
- }
-}
-
pjsip_module *PJSipSessionModule::getModule()
{
return &mModule;
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 14c9a3d..c2775d8 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -27,9 +27,6 @@ class PJSipSessionModule
public:
PJSipSessionModule();
pjsip_module *getModule();
- void replicateState(PJSipDialogModInfo *dlgInfo,
- PJSipTransactionModInfo *tsxInfo,
- PJSipSessionModInfo *sessionInfo);
private:
pjsip_module mModule;
pjsip_inv_callback mInvCallback;
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list