[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "transfer-improvements" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Jul 26 18:32:26 CDT 2011
branch "transfer-improvements" has been updated
via 8c16967c089d97469b3381470e86eef2a4c6b9e3 (commit)
via 19f4d921c290a54cb60e3c65c1620462938fbeb4 (commit)
via 86ec9fd0ec2fb144b9e9078545f3cf2d3bd7b7b6 (commit)
via cc932b659a3a6eb3fb6645782d7d8f79198e7928 (commit)
via 736155bbeb65c6636154eb241939bdee6ad97947 (commit)
via 234dc7763e10d70eb08cf135c7a58e0d0d3ad582 (commit)
via 9679afdc83b045a770a457d3bcc0f45d9e84031a (commit)
via 71ba00b4561400bff97a56810e107b9ed7e9e669 (commit)
via 14ab7604cb0ee0582db6b5a41ee9ba3687524ac2 (commit)
via 2db67876443174d96b30267d0a88f1c1110ae089 (commit)
via 2afea4f1b8883b67f76b2dfa8224ea0ee10f8dc1 (commit)
via 10aa09cab55db28069e710a5d61b6c6481953897 (commit)
via d944820463947d30de84fd81176c5c58d82a19ab (commit)
from f2ef25b81ccb00782d921aa14e3e891f4744dd09 (commit)
Summary of changes:
.../SipSessionManager/SipStateReplicationIf.ice | 4 +-
src/PJSipManager.cpp | 31 ----
src/PJSipManager.h | 2 -
src/PJSipSessionModule.cpp | 19 ++--
src/PJSipSessionModule.h | 72 +++-------
src/SipRegistrarListener.cpp | 5 +-
src/SipSession.cpp | 11 +-
src/SipSession.h | 2 +-
src/SipTransfer.cpp | 145 +++++++++++++-------
src/SipTransfer.h | 16 ++-
10 files changed, 149 insertions(+), 158 deletions(-)
- Log -----------------------------------------------------------------
commit 8c16967c089d97469b3381470e86eef2a4c6b9e3
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 18:32:54 2011 -0500
Get appropriate information to the TransferListener so it can send NOTIFYs.
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index d991da0..85cda24 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -77,7 +77,8 @@ using namespace AsteriskSCF::System::Hook::V1;
class TransferListener : public SessionListener
{
public:
- TransferListener()
+ TransferListener(pjsip_dialog *dlg, pj_int32_t referCSeq)
+ : mDialog(dlg), mReferCSeq(referCSeq)
{
}
@@ -98,6 +99,9 @@ public:
lg(Debug) << "Got the stopped indication. Should send some sort of final response sipfrag NOTIFY";
}
}
+private:
+ pjsip_dialog *mDialog;
+ pj_int32_t mReferCSeq;
};
typedef IceUtil::Handle<TransferListener> TransferListenerPtr;
@@ -107,8 +111,10 @@ class TransferSessionCreationHook : public SessionCreationHook
public:
TransferSessionCreationHook(
- const Ice::ObjectAdapterPtr& adapter)
- : mAdapter(adapter)
+ const Ice::ObjectAdapterPtr& adapter,
+ pjsip_dialog *dlg,
+ pj_int32_t referCSeq)
+ : mAdapter(adapter), mDialog(dlg), mReferCSeq(referCSeq)
{
}
@@ -129,7 +135,7 @@ private:
const SessionCreationHookDataPtr& original,
SessionCreationHookDataPtr& replacement)
{
- TransferListenerPtr transferListener = new TransferListener();
+ TransferListenerPtr transferListener = new TransferListener(mDialog, mReferCSeq);
SessionListenerPrx transferListenerPrx = SessionListenerPrx::uncheckedCast(mAdapter->addWithUUID(transferListener));
SessionListenerSeq listeners = original->listeners;
listeners.push_back(transferListenerPrx);
@@ -137,6 +143,8 @@ private:
replacement->listeners = listeners;
}
Ice::ObjectAdapterPtr mAdapter;
+ pjsip_dialog *mDialog;
+ pj_int32_t mReferCSeq;
};
typedef IceUtil::Handle<TransferSessionCreationHook> TransferSessionCreationHookPtr;
@@ -312,7 +320,7 @@ SuspendableWorkResult HandleReferOperation::initial(const SuspendableWorkListene
lg(Debug) << "Session to replace is with endpoint " << session->getEndpoint()->getName();
lg(Debug) << "Destination is " << mTarget;
mWasWithDestination = true;
- TransferSessionCreationHookPtr hook(new TransferSessionCreationHook(mAdapter));
+ TransferSessionCreationHookPtr hook(new TransferSessionCreationHook(mAdapter, mInv->dlg, mReferCSeq));
SessionCreationHookPrx hookPrx = SessionCreationHookPrx::uncheckedCast(mAdapter->addWithUUID(hook));
mHookPrxID = hookPrx->ice_getIdentity();
mSessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session->getSessionProxy(), mTarget, hookPrx, d);
commit 19f4d921c290a54cb60e3c65c1620462938fbeb4
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 18:29:15 2011 -0500
Move NOTIFY creation functions to anonymous namespace.
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index e4d08a4..d991da0 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -27,8 +27,42 @@ using namespace AsteriskSCF::System::Logging;
namespace
{
Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+
+pjsip_tx_data* createNotify(pjsip_dialog *dlg, pj_int32_t cseq)
+{
+ pjsip_tx_data *tdata;
+ pjsip_dlg_create_request(dlg, pjsip_get_notify_method(), -1, &tdata);
+
+ pjsip_event_hdr *event = pjsip_event_hdr_create(tdata->pool);
+ pj_strdup2(tdata->pool, &event->event_type, "refer");
+ char idbuf[20];
+ pj_ansi_snprintf(idbuf, sizeof(idbuf), "%d", cseq);
+ pj_strdup2(tdata->pool, &event->id_param, idbuf);
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) event);
+
+ pjsip_sub_state_hdr *subState = pjsip_sub_state_hdr_create(tdata->pool);
+ pj_strdup2(tdata->pool, &subState->sub_state, "terminated");
+ pj_strdup2(tdata->pool, &subState->reason_param, "noresource");
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) subState);
+
+ return tdata;
+}
+
+void addNotifyBody(pjsip_tx_data *tdata, const char *bodyText)
+{
+ pj_str_t type;
+ pj_cstr(&type, "message");
+ pj_str_t subtype;
+ pj_cstr(&subtype, "sipfrag;version=2.0");
+
+ pj_str_t bodyStr;
+ pj_cstr(&bodyStr, bodyText);
+ pjsip_msg_body *body = pjsip_msg_body_create(tdata->pool, &type, &subtype, &bodyStr);
+ tdata->msg->body = body;
}
+} //end anonymous namespace
+
namespace AsteriskSCF
{
@@ -301,7 +335,7 @@ SuspendableWorkResult HandleReferOperation::calledBack(const Ice::AsyncResultPtr
// We need to send a NOTIFY to indicate how things went on the other leg.
// XXX Once we have a subscription module written, we can actually use it.
- pjsip_tx_data *tdata = createNotify();
+ pjsip_tx_data *tdata = createNotify(mInv->dlg, mReferCSeq);
try
{
@@ -342,38 +376,5 @@ SuspendableWorkResult HandleReferOperation::calledBack(const Ice::AsyncResultPtr
return Complete;
}
-pjsip_tx_data* HandleReferOperation::createNotify()
-{
- pjsip_tx_data *tdata;
- pjsip_dlg_create_request(mInv->dlg, pjsip_get_notify_method(), -1, &tdata);
-
- pjsip_event_hdr *event = pjsip_event_hdr_create(tdata->pool);
- pj_strdup2(tdata->pool, &event->event_type, "refer");
- char idbuf[20];
- pj_ansi_snprintf(idbuf, sizeof(idbuf), "%d", mReferCSeq);
- pj_strdup2(tdata->pool, &event->id_param, idbuf);
- pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) event);
-
- pjsip_sub_state_hdr *subState = pjsip_sub_state_hdr_create(tdata->pool);
- pj_strdup2(tdata->pool, &subState->sub_state, "terminated");
- pj_strdup2(tdata->pool, &subState->reason_param, "noresource");
- pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) subState);
-
- return tdata;
-}
-
-void HandleReferOperation::addNotifyBody(pjsip_tx_data *tdata, const char *bodyText)
-{
- pj_str_t type;
- pj_cstr(&type, "message");
- pj_str_t subtype;
- pj_cstr(&subtype, "sipfrag;version=2.0");
-
- pj_str_t bodyStr;
- pj_cstr(&bodyStr, bodyText);
- pjsip_msg_body *body = pjsip_msg_body_create(tdata->pool, &type, &subtype, &bodyStr);
- tdata->msg->body = body;
-}
-
}; //end namespace SipSessionManager
}; //end namespace AsteriskSCF
diff --git a/src/SipTransfer.h b/src/SipTransfer.h
index 78b5fde..f607429 100644
--- a/src/SipTransfer.h
+++ b/src/SipTransfer.h
@@ -65,11 +65,6 @@ protected:
const Ice::AsyncResultPtr& asyncResult);
private:
-
- pjsip_tx_data* createNotify();
-
- void addNotifyBody(pjsip_tx_data *tdata, const char *bodyText);
-
/**
* The INVITE session, which contains the dialog on which the
* REFER was received.
commit 86ec9fd0ec2fb144b9e9078545f3cf2d3bd7b7b6
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 18:19:13 2011 -0500
Adjust functions to match bug fixes made in master.
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index 067912a..e4d08a4 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -294,10 +294,9 @@ SuspendableWorkResult HandleReferOperation::initial(const SuspendableWorkListene
}
};
-SuspendableWorkResult HandleReferOperation::calledBack(const SuspendableWorkListenerPtr&)
+SuspendableWorkResult HandleReferOperation::calledBack(const Ice::AsyncResultPtr& asyncResult)
{
- assert(mAsyncResult);
- SessionRouterPrx router = SessionRouterPrx::uncheckedCast(mAsyncResult->getProxy());
+ SessionRouterPrx router = SessionRouterPrx::uncheckedCast(asyncResult->getProxy());
// We need to send a NOTIFY to indicate how things went on the other leg.
// XXX Once we have a subscription module written, we can actually use it.
@@ -308,11 +307,11 @@ SuspendableWorkResult HandleReferOperation::calledBack(const SuspendableWorkList
{
if (mWasWithDestination)
{
- router->end_connectBridgedSessionsWithDestination(mAsyncResult);
+ router->end_connectBridgedSessionsWithDestination(asyncResult);
}
else
{
- router->end_connectBridgedSessions(mAsyncResult);
+ router->end_connectBridgedSessions(asyncResult);
}
}
catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
diff --git a/src/SipTransfer.h b/src/SipTransfer.h
index 575307f..78b5fde 100644
--- a/src/SipTransfer.h
+++ b/src/SipTransfer.h
@@ -62,7 +62,7 @@ protected:
* this is where the final work is done
*/
AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult calledBack(
- const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkListenerPtr&);
+ const Ice::AsyncResultPtr& asyncResult);
private:
commit cc932b659a3a6eb3fb6645782d7d8f79198e7928
Merge: 234dc77 736155b
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 17:59:28 2011 -0500
Merge branch 'master' into transfer-improvements
Conflicts:
src/PJSipSessionModule.cpp
diff --cc src/PJSipSessionModule.cpp
index 0ea8602,90da6e7..258239b
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@@ -963,17 -1202,16 +963,16 @@@ protected
return Complete;
}
- SuspendableWorkResult calledBack(const SuspendableWorkListenerPtr&)
+ SuspendableWorkResult calledBack(const Ice::AsyncResultPtr& asyncResult)
{
- assert(mAsyncResult);
- SessionListenerPrx listener = SessionListenerPrx::uncheckedCast(mAsyncResult->getProxy());
+ SessionListenerPrx listener = SessionListenerPrx::uncheckedCast(asyncResult->getProxy());
try
{
- listener->end_indicated(mAsyncResult);
+ listener->end_indicated(asyncResult);
}
- catch (const Ice::Exception&)
+ catch (const Ice::Exception& ex)
{
- lg(Error) << "Ice exception when attempting to indicate something or other";
+ lg(Error) << "Ice exception when attempting to indicate something or other: " << ex.what();
}
return Complete;
}
commit 736155bbeb65c6636154eb241939bdee6ad97947
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 17:57:56 2011 -0500
Properly deal with multiple AMI calls in a single queued operation.
This likely will fix an intermittent crash I was seeing, plus it fixes
a more direct bug I found in the transfer-improvements branch.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 9f2fe59..90da6e7 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -523,12 +523,12 @@ protected:
return Complete;
}
- SuspendableWorkResult calledBack(const SuspendableWorkListenerPtr&)
+ SuspendableWorkResult calledBack(const Ice::AsyncResultPtr& asyncResult)
{
- SessionRouterPrx router = SessionRouterPrx::uncheckedCast(mAsyncResult->getProxy());
+ SessionRouterPrx router = SessionRouterPrx::uncheckedCast(asyncResult->getProxy());
try
{
- router->end_routeSession(mAsyncResult);
+ router->end_routeSession(asyncResult);
}
catch (const DestinationNotFoundException &)
{
@@ -892,19 +892,18 @@ protected:
* Once the routing service has allowed for work to be resumed,
* this is where the final work is done
*/
- SuspendableWorkResult calledBack(const SuspendableWorkListenerPtr&)
+ SuspendableWorkResult calledBack(const Ice::AsyncResultPtr& asyncResult)
{
- assert(mAsyncResult);
- SessionRouterPrx router = SessionRouterPrx::uncheckedCast(mAsyncResult->getProxy());
+ SessionRouterPrx router = SessionRouterPrx::uncheckedCast(asyncResult->getProxy());
try
{
if (mWasWithDestination)
{
- router->end_connectBridgedSessionsWithDestination(mAsyncResult);
+ router->end_connectBridgedSessionsWithDestination(asyncResult);
}
else
{
- router->end_connectBridgedSessions(mAsyncResult);
+ router->end_connectBridgedSessions(asyncResult);
}
}
catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException &)
@@ -1203,13 +1202,12 @@ protected:
return Complete;
}
- SuspendableWorkResult calledBack(const SuspendableWorkListenerPtr&)
+ SuspendableWorkResult calledBack(const Ice::AsyncResultPtr& asyncResult)
{
- assert(mAsyncResult);
- SessionListenerPrx listener = SessionListenerPrx::uncheckedCast(mAsyncResult->getProxy());
+ SessionListenerPrx listener = SessionListenerPrx::uncheckedCast(asyncResult->getProxy());
try
{
- listener->end_indicated(mAsyncResult);
+ listener->end_indicated(asyncResult);
}
catch (const Ice::Exception&)
{
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index a90ef7d..79b0212 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -176,40 +176,15 @@ typedef IceUtil::Handle<PJSipSessionModule> PJSipSessionModulePtr;
class SipQueueableOperation : virtual public AsteriskSCF::System::WorkQueue::V1::SuspendableWork
{
public:
- SipQueueableOperation() : mState(Initial) { }
+ SipQueueableOperation() { }
virtual ~SipQueueableOperation() { }
- /**
- * Queueable operations may call out to AMI methods. AMI callbacks happen
- * in Ice client threads. We want to process the result of the AMI call in one
- * of our thread pool's threads, though. The AMI callback can set the operation's
- * AsyncResult so that the operation may process the result of the AMI call in
- * one of our threads.
- */
- void setAsyncResult(const Ice::AsyncResultPtr& r) {mAsyncResult = r;}
/**
* Override of SuspendableWorkExecute()
*/
AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult execute(const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkListenerPtr& listener)
{
- AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult result =
- AsteriskSCF::System::WorkQueue::V1::Complete;
- switch (mState)
- {
- case Initial:
- result = initial(listener);
- // Change the state now so that
- // when the AMI callback occurs,
- // the proper followup will be called.
- mState = CalledBack;
- break;
- case CalledBack:
- result = calledBack(listener);
- break;
- default:
- break;
- }
- return result;
+ return initial(listener);
}
protected:
@@ -220,6 +195,7 @@ protected:
virtual AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult initial(
const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkListenerPtr&) = 0;
+public:
/**
* If a SipQueueableOperation has made an AMI call, then when the AMI method
* returns, this will be where the AMI result can be processed.
@@ -228,36 +204,29 @@ protected:
* not always be overloaded.
*/
virtual AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult calledBack(
- const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkListenerPtr&)
+ const Ice::AsyncResultPtr&)
{
return AsteriskSCF::System::WorkQueue::V1::Complete;
}
-
- enum states
- {
- /**
- * State of the operation upon construction.
- * @see initial
- */
- Initial,
- /**
- * State when AMI result is received.
- * @see calledBack
- */
- CalledBack,
- } mState;
-
- /**
- * Ice asynchronous result.
- *
- * Used for processing the result of AMI calls.
- * @see setAsyncResult
- */
- Ice::AsyncResultPtr mAsyncResult;
};
typedef IceUtil::Handle<SipQueueableOperation> SipQueueableOperationPtr;
+class SipAMICallbackOperation : public AsteriskSCF::System::WorkQueue::V1::SuspendableWork
+{
+public:
+ SipAMICallbackOperation(const Ice::AsyncResultPtr& r, const SipQueueableOperationPtr& operation)
+ : mAsyncResultPtr(r), mOperation(operation) { }
+ AsteriskSCF::System::WorkQueue::V1::SuspendableWorkResult execute(
+ const AsteriskSCF::System::WorkQueue::V1::SuspendableWorkListenerPtr&)
+ {
+ return mOperation->calledBack(mAsyncResultPtr);
+ }
+private:
+ Ice::AsyncResultPtr mAsyncResultPtr;
+ SipQueueableOperationPtr mOperation;
+};
+
/**
* General AMI callback class used with SipQueueableOperation
*
@@ -282,14 +251,13 @@ public:
void callback(const Ice::AsyncResultPtr &r)
{
- mOperation->setAsyncResult(r);
if (mIsSuspended)
{
mListener->workResumable();
}
else if (mNeedsRequeuing)
{
- mSession->enqueueSessionWork(mOperation);
+ mSession->enqueueSessionWork(new SipAMICallbackOperation(r, mOperation));
}
}
commit 234dc7763e10d70eb08cf135c7a58e0d0d3ad582
Merge: 71ba00b 9679afd
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 13:08:33 2011 -0500
Merge branch 'master' into transfer-improvements
commit 9679afdc83b045a770a457d3bcc0f45d9e84031a
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 13:07:26 2011 -0500
Don't push NULL endpoints onto the sequence to update when listening for REGISTERs.
diff --git a/src/SipRegistrarListener.cpp b/src/SipRegistrarListener.cpp
index 29a10e7..8c323c4 100644
--- a/src/SipRegistrarListener.cpp
+++ b/src/SipRegistrarListener.cpp
@@ -49,7 +49,10 @@ SipEndpointSeq SipDefaultRegistrarListener::getEndpoints(pj_pool_t *pool, const
lg(Debug) << "Extracted endpoint name " << aorUser << " from aor";
SipEndpointPtr endpoint = mEndpointFactory->findByName(aorUser);
SipEndpointSeq endpointSeq;
- endpointSeq.push_back(endpoint);
+ if (endpoint)
+ {
+ endpointSeq.push_back(endpoint);
+ }
return endpointSeq;
}
commit 71ba00b4561400bff97a56810e107b9ed7e9e669
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 13:06:28 2011 -0500
Add session listener on transfer. Fix some ambiguity with a type name. Add debugging to an exception I was having.
diff --git a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
index 59e121c..4a48474 100644
--- a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
@@ -144,8 +144,6 @@ module V1
bool mIsClient;
};
- sequence<AsteriskSCF::SessionCommunications::V1::SessionListener*> SessionListenerSeq;
-
sequence<AsteriskSCF::Media::RTP::V1::RTPSession*> RTPMediaSessionSeq;
class SipSessionStateItem extends SipStateItem
@@ -158,7 +156,7 @@ module V1
AsteriskSCF::Media::V1::StreamSourceSeq mSources;
AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
RTPMediaSessionSeq mRTPMediaSessions;
- SessionListenerSeq mListeners;
+ AsteriskSCF::SessionCommunications::V1::SessionListenerSeq mListeners;
AsteriskSCF::SessionCommunications::V1::Bridge *mBridge;
AsteriskSCF::SessionCommunications::V1::SessionCookieDict mCookies;
};
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index ee796ef..0ea8602 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -971,9 +971,9 @@ protected:
{
listener->end_indicated(mAsyncResult);
}
- catch (const Ice::Exception&)
+ catch (const Ice::Exception& ex)
{
- lg(Error) << "Ice exception when attempting to indicate something or other";
+ lg(Error) << "Ice exception when attempting to indicate something or other: " << ex.what();
}
return Complete;
}
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index d4d11aa..d8d0a76 100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1942,7 +1942,7 @@ AsteriskSCF::Media::V1::SessionPrx& SipSession::getMediaSessionProxy()
/**
* Internal function which sets the listeners explicitly.
*/
-void SipSession::setListeners(const SessionListenerSeq& listeners)
+void SipSession::setListeners(const AsteriskSCF::SessionCommunications::V1::SessionListenerSeq& listeners)
{
mImplPriv->mListeners = listeners;
}
diff --git a/src/SipSession.h b/src/SipSession.h
index 9a88f77..ad50231 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -232,7 +232,7 @@ public:
AsteriskSCF::Media::V1::SessionPrx& getMediaSessionProxy();
- void setListeners(const AsteriskSCF::Replication::SipSessionManager::V1::SessionListenerSeq&);
+ void setListeners(const AsteriskSCF::SessionCommunications::V1::SessionListenerSeq&);
AsteriskSCF::Replication::SipSessionManager::V1::RTPMediaSessionSeq getRTPMediaSessions();
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index 98caf30..067912a 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -42,6 +42,7 @@ using namespace AsteriskSCF::System::Hook::V1;
class TransferListener : public SessionListener
{
+public:
TransferListener()
{
}
@@ -53,13 +54,20 @@ class TransferListener : public SessionListener
const Ice::Current&)
{
ConnectedIndicationPtr connected;
+ StoppedIndicationPtr stopped;
if ((connected = ConnectedIndicationPtr::dynamicCast(event)))
{
lg(Debug) << "Got the connected indication. Should send a 200 sipfrag NOTIFY";
}
+ if ((stopped = StoppedIndicationPtr::dynamicCast(event)))
+ {
+ lg(Debug) << "Got the stopped indication. Should send some sort of final response sipfrag NOTIFY";
+ }
}
};
+typedef IceUtil::Handle<TransferListener> TransferListenerPtr;
+
class TransferSessionCreationHook : public SessionCreationHook
{
@@ -75,7 +83,6 @@ public:
SessionCreationHookDataPtr& replacementData,
const Ice::Current&)
{
- lg(Debug) << "Told to modify the session...good sign!!!";
replacementData = new SessionCreationHookData();
setStuff(originalData, replacementData);
HookResult result;
@@ -88,8 +95,12 @@ private:
const SessionCreationHookDataPtr& original,
SessionCreationHookDataPtr& replacement)
{
+ TransferListenerPtr transferListener = new TransferListener();
+ SessionListenerPrx transferListenerPrx = SessionListenerPrx::uncheckedCast(mAdapter->addWithUUID(transferListener));
+ SessionListenerSeq listeners = original->listeners;
+ listeners.push_back(transferListenerPrx);
replacement->session = original->session;
- replacement->listeners = original->listeners;
+ replacement->listeners = listeners;
}
Ice::ObjectAdapterPtr mAdapter;
};
commit 14ab7604cb0ee0582db6b5a41ee9ba3687524ac2
Author: Brent Eagles <beagles at digium.com>
Date: Tue Jul 26 15:26:29 2011 -0230
Remove creation of UDP transport by default.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index eab06d5..1618b4e 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -99,7 +99,6 @@ static void *monitorThread(void *endpt)
PJSipManagerPtr AsteriskSCF::SipSessionManager::PJSipManager::create(const Ice::PropertiesPtr& properties)
{
PJSipManagerPtr result(new PJSipManager);
- result->initializeDefaultTransports(properties);
STUNModulePtr stunModule = STUNModule::create(result, properties, logger);
result->addModule("STUN", stunModule);
return result;
@@ -259,36 +258,6 @@ pj_pool_t* PJSipManager::getMemoryPool()
return mMemoryPool;
}
-void PJSipManager::initializeDefaultTransports(const Ice::PropertiesPtr& properties)
-{
- string bindAddress = properties->getPropertyWithDefault("Sip.Transport.UdpBindAddr", "0.0.0.0:5060");
- string addressPart;
- int portPart = 5060;
- size_t colon = bindAddress.rfind(':');
- if (colon != string::npos)
- {
- addressPart = bindAddress.substr(0, colon);
- portPart = boost::lexical_cast<int>(bindAddress.substr(colon+1));
- }
- else
- {
- addressPart = bindAddress;
- }
- //
- // It is entirely possible that the default transport is instantiable. We'll eat this error for
- // now, but it might be better to abort out.
- //
- TransportPtr defaultUDPTransport = createUDPTransport(shared_from_this(), addressPart, portPart);
- if (defaultUDPTransport)
- {
- mTransports.insert(make_pair(defaultUDPTransport->id(), defaultUDPTransport));
- }
- else
- {
- logger(Error) << "Unable to create default transport";
- }
-}
-
PJSipManager::PJSipManager() :
mEndpoint(0),
mSessionModule(0),
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index f18bc9c..e26acf1 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -144,8 +144,6 @@ private:
SipModuleMap mModules;
std::map<std::string, TransportPtr> mTransports;
- void initializeDefaultTransports(const Ice::PropertiesPtr& properties);
-
PJSipManager();
};
commit 2db67876443174d96b30267d0a88f1c1110ae089
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 11:12:24 2011 -0500
Make refinements to ensure one-shot hook is called properly and things don't break.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 37d7fbe..d4d11aa 100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -422,9 +422,6 @@ void SipSession::initializePJSIPStructs()
void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq& hooks)
{
- mImplPriv->mSessionProxy =
- AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
-
AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr initial(new AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookData(mImplPriv->mSessionProxy, mImplPriv->mListeners));
AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr in = initial;
@@ -478,6 +475,9 @@ SipSession::SipSession(
mImplPriv->mListeners.push_back(listener);
}
+ mImplPriv->mSessionProxy =
+ AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
+
mImplPriv->mMediaSession = new SipMediaSession(this);
mImplPriv->mMediaSessionProxy =
AsteriskSCF::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mImplPriv->mMediaSession));
@@ -516,6 +516,9 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter,
const NATEndpointOptions& natOptions)
: mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica, natOptions))
{
+ mImplPriv->mSessionProxy =
+ AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
+
mImplPriv->mMediaSession = new SipMediaSession(this);
mImplPriv->mMediaSessionProxy =
AsteriskSCF::Media::V1::SessionPrx::uncheckedCast(adapter->add(mImplPriv->mMediaSession, mediaid));
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index 275131f..98caf30 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -71,17 +71,26 @@ public:
}
HookResult modifySession(
- const SessionCreationHookDataPtr&,
- SessionCreationHookDataPtr&,
+ const SessionCreationHookDataPtr& originalData,
+ SessionCreationHookDataPtr& replacementData,
const Ice::Current&)
{
lg(Debug) << "Told to modify the session...good sign!!!";
+ replacementData = new SessionCreationHookData();
+ setStuff(originalData, replacementData);
HookResult result;
result.status = Succeeded;
return result;
}
private:
+ void setStuff(
+ const SessionCreationHookDataPtr& original,
+ SessionCreationHookDataPtr& replacement)
+ {
+ replacement->session = original->session;
+ replacement->listeners = original->listeners;
+ }
Ice::ObjectAdapterPtr mAdapter;
};
commit 2afea4f1b8883b67f76b2dfa8224ea0ee10f8dc1
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 10:40:41 2011 -0500
Transfer session creation hook is created and removed from object adapter on exceptions.
Going to run a quick test to make sure the hook gets created and called into properly
on session creation. Wish me luck.
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index 2f94348..275131f 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -62,8 +62,11 @@ class TransferListener : public SessionListener
class TransferSessionCreationHook : public SessionCreationHook
{
+
public:
- TransferSessionCreationHook()
+ TransferSessionCreationHook(
+ const Ice::ObjectAdapterPtr& adapter)
+ : mAdapter(adapter)
{
}
@@ -72,10 +75,14 @@ public:
SessionCreationHookDataPtr&,
const Ice::Current&)
{
+ lg(Debug) << "Told to modify the session...good sign!!!";
HookResult result;
result.status = Succeeded;
return result;
}
+
+private:
+ Ice::ObjectAdapterPtr mAdapter;
};
typedef IceUtil::Handle<TransferSessionCreationHook> TransferSessionCreationHookPtr;
@@ -251,8 +258,10 @@ SuspendableWorkResult HandleReferOperation::initial(const SuspendableWorkListene
lg(Debug) << "Session to replace is with endpoint " << session->getEndpoint()->getName();
lg(Debug) << "Destination is " << mTarget;
mWasWithDestination = true;
- TransferSessionCreationHookPtr hook(new TransferSessionCreationHook());
- mSessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session->getSessionProxy(), mTarget, 0, d);
+ TransferSessionCreationHookPtr hook(new TransferSessionCreationHook(mAdapter));
+ SessionCreationHookPrx hookPrx = SessionCreationHookPrx::uncheckedCast(mAdapter->addWithUUID(hook));
+ mHookPrxID = hookPrx->ice_getIdentity();
+ mSessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session->getSessionProxy(), mTarget, hookPrx, d);
return Complete;
}
catch (const Ice::CommunicatorDestroyedException &)
@@ -286,20 +295,22 @@ SuspendableWorkResult HandleReferOperation::calledBack(const SuspendableWorkList
router->end_connectBridgedSessions(mAsyncResult);
}
}
- catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException &)
+ catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
{
lg(Debug) << "ConnectBridgedSessionsWithDestination sending 404 due to destination not found.";
addNotifyBody(tdata, "SIP/2.0 404 Not Found");
pjsip_dlg_send_request(mInv->dlg, tdata, -1, NULL);
+ mAdapter->remove(mHookPrxID);
return Complete;
}
- catch (const std::exception &e)
+ catch (const std::exception& e)
{
lg(Debug) << "ConnectBridgedSessionsCallback sending 400 due to exception: " << e.what();
addNotifyBody(tdata, "SIP/2.0 400 Bad Request");
pjsip_dlg_send_request(mInv->dlg, tdata, -1, NULL);
+ mAdapter->remove(mHookPrxID);
return Complete;
}
diff --git a/src/SipTransfer.h b/src/SipTransfer.h
index 8bbfef2..575307f 100644
--- a/src/SipTransfer.h
+++ b/src/SipTransfer.h
@@ -137,6 +137,10 @@ private:
* instead.
*/
bool mWasWithDestination;
+ /**
+ * The identity of the session creation hook we create.
+ */
+ Ice::Identity mHookPrxID;
};
}; //end namespace SipSessionManager
commit 10aa09cab55db28069e710a5d61b6c6481953897
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 10:19:59 2011 -0500
Add the object adapter to the HandleReferOperation.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 4fa519d..ee796ef 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -810,7 +810,7 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
}
lg(Debug) << "Queuing a HandleReferOperation";
- enqueueSessionWork(new HandleReferOperation(inv, tsx, tdata, replaces_param, to_tag_param, from_tag_param, referredByVal, target, session, mSessionRouter, mModule.id), inv);
+ enqueueSessionWork(new HandleReferOperation(inv, tsx, tdata, replaces_param, to_tag_param, from_tag_param, referredByVal, target, session, mSessionRouter, mAdapter, mModule.id), inv);
}
pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index d15303a..2f94348 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -91,6 +91,7 @@ HandleReferOperation::HandleReferOperation(
const std::string& target,
const SipSessionPtr& session,
const AsteriskSCF::Discovery::SmartProxy<SessionRouterPrx>& sessionRouter,
+ const Ice::ObjectAdapterPtr& adapter,
const int moduleId)
: mInv(inv), mTsx(tsx), mTdata(tdata),
mReplacesParam(replaces_param ? new pjsip_param(*replaces_param) : NULL),
@@ -98,7 +99,7 @@ HandleReferOperation::HandleReferOperation(
mFromTagParam(from_tag_param ? new pjsip_param(*from_tag_param) : NULL),
mReferredBy(referredBy),
mTarget(target),
- mSession(session), mSessionRouter(sessionRouter),
+ mSession(session), mSessionRouter(sessionRouter), mAdapter(adapter),
mModuleId(moduleId), mReferCSeq(tsx->cseq), mWasWithDestination(false) {}
HandleReferOperation::~HandleReferOperation()
diff --git a/src/SipTransfer.h b/src/SipTransfer.h
index 1cb95b1..8bbfef2 100644
--- a/src/SipTransfer.h
+++ b/src/SipTransfer.h
@@ -38,6 +38,7 @@ public:
const std::string& target,
const SipSessionPtr& session,
const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx>& sessionRouter,
+ const Ice::ObjectAdapterPtr& adapter,
const int moduleId);
~HandleReferOperation();
@@ -119,6 +120,10 @@ private:
*/
AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx> mSessionRouter;
/**
+ * Object adapter, for creating proxies to hooks and session listeners.
+ */
+ Ice::ObjectAdapterPtr mAdapter;
+ /**
* The identifier of the PJSipSessionModule. Used for retrieving module data from mInv
*/
const int mModuleId;
commit d944820463947d30de84fd81176c5c58d82a19ab
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Jul 26 10:07:32 2011 -0500
Make sure I can allocate a TransferSessionCreationHook if needed.
Small steps people...
diff --git a/src/SipTransfer.cpp b/src/SipTransfer.cpp
index f67ce78..d15303a 100644
--- a/src/SipTransfer.cpp
+++ b/src/SipTransfer.cpp
@@ -48,15 +48,21 @@ class TransferListener : public SessionListener
void indicated(
const SessionPrx&,
- const IndicationPtr&,
+ const IndicationPtr& event,
const SessionCookies&,
const Ice::Current&)
{
+ ConnectedIndicationPtr connected;
+ if ((connected = ConnectedIndicationPtr::dynamicCast(event)))
+ {
+ lg(Debug) << "Got the connected indication. Should send a 200 sipfrag NOTIFY";
+ }
}
};
class TransferSessionCreationHook : public SessionCreationHook
{
+public:
TransferSessionCreationHook()
{
}
@@ -72,6 +78,8 @@ class TransferSessionCreationHook : public SessionCreationHook
}
};
+typedef IceUtil::Handle<TransferSessionCreationHook> TransferSessionCreationHookPtr;
+
HandleReferOperation::HandleReferOperation(
pjsip_inv_session *inv,
pjsip_transaction *tsx,
@@ -242,6 +250,7 @@ SuspendableWorkResult HandleReferOperation::initial(const SuspendableWorkListene
lg(Debug) << "Session to replace is with endpoint " << session->getEndpoint()->getName();
lg(Debug) << "Destination is " << mTarget;
mWasWithDestination = true;
+ TransferSessionCreationHookPtr hook(new TransferSessionCreationHook());
mSessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session->getSessionProxy(), mTarget, 0, d);
return Complete;
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list