[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Sun Sep 11 22:52:45 CDT 2011
branch "master" has been updated
via ec01c62e89fc764c104d4552891d366db52ad9b9 (commit)
from 1c329a070da3354941507edd495c84d1cd0535ca (commit)
Summary of changes:
src/SipEndpoint.cpp | 42 ++++----
src/SipSession.cpp | 298 ++++++++++++++++++++++++++++++++++++++++++---------
src/SipSession.h | 7 +-
3 files changed, 272 insertions(+), 75 deletions(-)
- Log -----------------------------------------------------------------
commit ec01c62e89fc764c104d4552891d366db52ad9b9
Author: Ken Hunt <ken.hunt at digium.com>
Date: Sun Sep 11 22:52:07 2011 -0500
Support changes to API made for Media Session cookie support.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index dfaebf8..effd1f4 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -48,7 +48,7 @@ namespace AsteriskSCF
namespace SipSessionManager
{
-string cookieKey(string &endpointName, const SessionCookiePtr& cookie)
+string cookieKey(string &endpointName, const AsteriskSCF::SessionCommunications::V1::SessionCookiePtr& cookie)
{
string key = endpointName + "::" + cookie->ice_id();
return key;
@@ -185,7 +185,7 @@ public:
mName(name), mAdapter(adapter), mEndpointFactory(factory), mManager(manager), mServiceLocator(serviceLocator),
mReplicationContext(replicationContext),
mDefaultListeners(new AsteriskSCF::Collections::ProxySet<SessionListenerPrx>(adapter, lg, "Default Session Listeners")),
- mDefaultSessionCookies(new AsteriskSCF::Collections::HandleSet<SessionCookiePtr>(lg, "Default Cookies"))
+ mDefaultSessionCookies(new AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>(lg, "Default Cookies"))
{
};
@@ -238,7 +238,7 @@ public:
AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
SipReplicationContextPtr mReplicationContext;
AsteriskSCF::Collections::ProxySet<SessionListenerPrx>::SetPtr mDefaultListeners;
- AsteriskSCF::Collections::HandleSet<SessionCookiePtr>::SetPtr mDefaultSessionCookies;
+ AsteriskSCF::Collections::HandleSet<AsteriskSCF::SessionCommunications::V1::SessionCookiePtr>::SetPtr mDefaultSessionCookies;
};
SipEndpoint::SipEndpoint(const Ice::ObjectAdapterPtr& adapter,
@@ -402,7 +402,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(
listeners.push_back(listener);
}
- SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
+ AsteriskSCF::SessionCommunications::V1::SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
SipSessionPtr session = SipSession::create(
mImplPriv->mAdapter,
@@ -430,7 +430,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(
AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
{
vector<SessionListenerPrx> defaultListeners = mImplPriv->mDefaultListeners->getAll();
- SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
+ AsteriskSCF::SessionCommunications::V1::SessionCookies defaultCookies = mImplPriv->mDefaultSessionCookies->getAll();
SipSessionPtr session = SipSession::create(
mImplPriv->mAdapter,
@@ -575,13 +575,14 @@ void SipEndpoint::removeDefaultSessionListener(const SessionListenerPrx& listene
/**
* Copies the input cookies minus the read-only cookies.
*/
-SessionCookies filterReadOnlyCookies(const SessionCookies& cookiesIn, const std::string& logMessage)
+AsteriskSCF::SessionCommunications::V1::SessionCookies
+ filterReadOnlyCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookiesIn, const std::string& logMessage)
{
- SessionCookies cookiesOut;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies cookiesOut;
// Filter out any read-only cookies passed in. They must be set through specific API calls,
// not via generic cookie API.
- for(SessionCookies::const_iterator i=cookiesIn.begin(); i != cookiesIn.end(); ++i)
+ for(AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i=cookiesIn.begin(); i != cookiesIn.end(); ++i)
{
if (SipSession::isSessionCookieReadOnly(*i))
{
@@ -598,9 +599,9 @@ SessionCookies filterReadOnlyCookies(const SessionCookies& cookiesIn, const std:
* @param cookies A sequence of cookies to be removed.
* @param privileged Indicates if the calling operation has privilege to alter read-only cookies.
*/
-void SipEndpoint::addDefaultSessionCookies(const SessionCookies& cookies, bool privileged)
+void SipEndpoint::addDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, bool privileged)
{
- SessionCookies modCookies;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies modCookies;
if (privileged)
{
@@ -621,7 +622,7 @@ void SipEndpoint::addDefaultSessionCookies(const SessionCookies& cookies, bool p
// Replicate this change.
SipStateItemSeq items;
- for(SessionCookies::const_iterator i=modCookies.begin(); i != modCookies.end(); ++i)
+ for(AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i=modCookies.begin(); i != modCookies.end(); ++i)
{
items.push_back(new DefaultSessionCookieItem(cookieKey(mImplPriv->mName, *i),
"",
@@ -632,8 +633,7 @@ void SipEndpoint::addDefaultSessionCookies(const SessionCookies& cookies, bool p
mImplPriv->mReplicationContext->getReplicator().tryOneWay()->setState(items);
}
-
-void SipEndpoint::addDefaultSessionCookies(const SessionCookies& cookies, const Ice::Current&)
+void SipEndpoint::addDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, const Ice::Current&)
{
addDefaultSessionCookies(cookies, false);
}
@@ -643,9 +643,9 @@ void SipEndpoint::addDefaultSessionCookies(const SessionCookies& cookies, const
* @param cookies A sequence of cookies to be removed.
* @param privileged Indicates if the calling operation has privilege to alter read-only cookies.
*/
-void SipEndpoint::removeDefaultSessionCookies(const SessionCookies& cookies, bool privileged)
+void SipEndpoint::removeDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, bool privileged)
{
- SessionCookies modCookies;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies modCookies;
if (privileged)
{
@@ -666,7 +666,7 @@ void SipEndpoint::removeDefaultSessionCookies(const SessionCookies& cookies, boo
// Replicate this change.
SipStateItemSeq items;
- for(SessionCookies::const_iterator i=modCookies.begin(); i != modCookies.end(); ++i)
+ for(AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i=modCookies.begin(); i != modCookies.end(); ++i)
{
items.push_back(new DefaultSessionCookieItem(cookieKey(mImplPriv->mName, *i),
"",
@@ -677,21 +677,21 @@ void SipEndpoint::removeDefaultSessionCookies(const SessionCookies& cookies, boo
mImplPriv->mReplicationContext->getReplicator().tryOneWay()->removeStateForItems(items);
}
-void SipEndpoint::removeDefaultSessionCookies(const SessionCookies& cookies, const Ice::Current&)
+void SipEndpoint::removeDefaultSessionCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, const Ice::Current&)
{
removeDefaultSessionCookies(cookies, false);
}
-void SipEndpoint::addDefaultSessionCookie(const SessionCookiePtr& cookie)
+void SipEndpoint::addDefaultSessionCookie(const AsteriskSCF::SessionCommunications::V1::SessionCookiePtr& cookie)
{
- SessionCookies cookies;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies cookies;
cookies.push_back(cookie);
addDefaultSessionCookies(cookies, true);
}
-void SipEndpoint::removeDefaultSessionCookie(const SessionCookiePtr& cookie)
+void SipEndpoint::removeDefaultSessionCookie(const AsteriskSCF::SessionCommunications::V1::SessionCookiePtr& cookie)
{
- SessionCookies cookies;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies cookies;
cookies.push_back(cookie);
removeDefaultSessionCookies(cookies, true);
}
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index b06a154..bad71eb 100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -39,6 +39,7 @@
#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
#include <AsteriskSCF/SessionCookies/SipSessionManager/SipSessionCookiesIf.h>
+#include <AsteriskSCF/Collections/HandleSet.h>
#include "NATOptions.h"
using namespace AsteriskSCF::System::Logging;
@@ -64,38 +65,6 @@ namespace SipSessionManager
using namespace AsteriskSCF::System::WorkQueue::V1;
-class SipMediaSession : public Media::V1::Session
-{
-public:
- SipMediaSession(const SipSessionPtr& session) : mId(IceUtil::generateUUID()), mSession(session) { };
-
- AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&)
- {
- return mSession->getMediaSources();
- }
-
- AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&)
- {
- return mSession->getMediaSinks();
- }
-
- virtual std::string getId(const Ice::Current&)
- {
- return mId;
- }
-
-private:
- /**
- * Unique identifier for the media session.
- */
- std::string mId;
-
- /**
- * A pointer to the communications session that created us.
- */
- SipSessionPtr mSession;
-};
-
/**
* A class that identifies a set of read-only cookie types.
* The types in this set will be protected from being altered
@@ -408,7 +377,6 @@ private:
}; // class SipSessionPriv
typedef boost::shared_ptr<SipSessionPriv> SipSessionPrivPtr;
-
ReadOnlyCookieTypes SipSessionPriv::mReadOnlyCookieTypes;
/**
@@ -420,6 +388,192 @@ bool SipSession::isSessionCookieReadOnly(const AsteriskSCF::SessionCommunication
}
/**
+ * Get the specified cookies from the media sessions and pass it to
+ * the given AMD callback handle.
+ */
+class GetMediaSessionCookiesOperation : public SuspendableWork
+{
+public:
+ /**
+ * ctor()
+ * @param cb The AMD callback reference.
+ * @param cookieTypes The cookies to get.
+ * @param sessionPriv The session for whom the information is requested from.
+ */
+ GetMediaSessionCookiesOperation(
+ const AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr& cb,
+ const AsteriskSCF::Media::V1::SessionCookies& cookieTypes,
+ const SipSessionPtr& session)
+ : mCb(cb), mCookieTypes(cookieTypes), mSession(session)
+ {
+ }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ lg(Debug) << "Executing a GetMediaSessionCookiesOperation operation";
+
+ AsteriskSCF::Media::V1::SessionCookies results;
+
+ // Gather the cookies from all of the Session's RTP Media Sessions.
+ RTPMediaSessionSeq mediaSessions = mSession->getRTPMediaSessions();
+ for(RTPMediaSessionSeq::iterator i = mediaSessions.begin();
+ i != mediaSessions.end(); ++i)
+ {
+ AsteriskSCF::Media::V1::SessionCookies cookies = (*i)->getCookies(mCookieTypes);
+ results.insert(results.end(), cookies.begin(), cookies.end());
+ }
+
+ mCb->ice_response(results);
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr mCb;
+ AsteriskSCF::Media::V1::SessionCookies mCookieTypes;
+ SipSessionPtr mSession;
+};
+
+/**
+ * Set the specified cookies on the media sessions.
+ */
+class SetMediaSessionCookiesOperation : public SuspendableWork
+{
+public:
+ /**
+ * ctor()
+ * @param cookieTypes The cookies to get.
+ * @param sessionPriv The session for whom the information is requested from.
+ */
+ SetMediaSessionCookiesOperation(
+ const AsteriskSCF::Media::V1::SessionCookies& cookies,
+ const SipSessionPtr& session)
+ : mCookies(cookies), mSession(session)
+ {
+ }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ lg(Debug) << "Executing a SetMediaSessionCookiesOperation operation";
+
+ AsteriskSCF::Media::V1::SessionCookies results;
+
+ // Set the cookies on all of the Session's RTP Media Sessions.
+ RTPMediaSessionSeq mediaSessions = mSession->getRTPMediaSessions();
+ for(RTPMediaSessionSeq::iterator i = mediaSessions.begin();
+ i != mediaSessions.end(); ++i)
+ {
+ (*i)->setCookies(mCookies);
+ }
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::Media::V1::SessionCookies mCookies;
+ SipSessionPtr mSession;
+};
+
+/**
+ * Remove the specified cookies from the media sessions.
+ */
+class RemoveMediaSessionCookiesOperation : public SuspendableWork
+{
+public:
+ /**
+ * ctor()
+ * @param cookieTypes The cookies to get.
+ * @param sessionPriv The session for whom the information is requested from.
+ */
+ RemoveMediaSessionCookiesOperation(
+ const AsteriskSCF::Media::V1::SessionCookies& cookieTypes,
+ const SipSessionPtr& session)
+ : mCookieTypes(cookieTypes), mSession(session)
+ {
+ }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ lg(Debug) << "Executing a RemoveMediaSessionCookiesOperation operation";
+
+ AsteriskSCF::Media::V1::SessionCookies results;
+
+ // Set the cookies on all of the Session's RTP Media Sessions.
+ RTPMediaSessionSeq mediaSessions = mSession->getRTPMediaSessions();
+ for(RTPMediaSessionSeq::iterator i = mediaSessions.begin();
+ i != mediaSessions.end(); ++i)
+ {
+ (*i)->removeCookies(mCookieTypes);
+ }
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::Media::V1::SessionCookies mCookieTypes;
+ SipSessionPtr mSession;
+};
+
+/**
+ * Servant for the Sessions's media Session interface.
+ */
+class SipMediaSession : public Media::V1::Session
+{
+public:
+ SipMediaSession(const SipSessionPtr& session)
+ : mId(IceUtil::generateUUID()),
+ mSession(session)
+ {
+ }
+
+ AsteriskSCF::Media::V1::StreamSourceSeq getSources(const Ice::Current&)
+ {
+ return mSession->getMediaSources();
+ }
+
+ AsteriskSCF::Media::V1::StreamSinkSeq getSinks(const Ice::Current&)
+ {
+ return mSession->getMediaSinks();
+ }
+
+ virtual std::string getId(const Ice::Current&)
+ {
+ return mId;
+ }
+
+ void setCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies,
+ const Ice::Current&)
+ {
+ mSession->enqueueSessionWork(new SetMediaSessionCookiesOperation(cookies, mSession));
+ }
+
+ void getCookies_async(
+ const ::AsteriskSCF::Media::V1::AMD_Session_getCookiesPtr& cb,
+ const AsteriskSCF::Media::V1::SessionCookies& cookiesToGet,
+ const Ice::Current&)
+ {
+ mSession->enqueueSessionWork(new GetMediaSessionCookiesOperation(cb, cookiesToGet, mSession));
+ }
+
+ void removeCookies(const AsteriskSCF::Media::V1::SessionCookies& cookies,
+ const Ice::Current&)
+ {
+ mSession->enqueueSessionWork(new RemoveMediaSessionCookiesOperation(cookies, mSession));
+ }
+
+private:
+ /**
+ * Unique identifier for the media session.
+ */
+ std::string mId;
+
+ /**
+ * A pointer to the communications session that created us.
+ */
+ SipSessionPtr mSession;
+};
+
+/**
* Template for allocating from a pool.
*/
template<typename T>
@@ -656,9 +810,9 @@ public:
{
lg(Debug) << "Executing an UpdateRedirecting operation";
- SessionCookieDict cookies = mSession->getAllCookies();
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict cookies = mSession->getAllCookies();
- SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(mRedirecting->ice_id());
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(mRedirecting->ice_id());
int updatedCount = 1;
if (search != cookies.end())
@@ -785,7 +939,7 @@ void SipSession::setSelfAsCaller()
{
// Note: The SessionOwnerId is set via a default cookie added to the Endpoint.
SessionOwnerIdPtr test = new SessionOwnerId();
- SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
if (search == mImplPriv->mSessionCookies.end())
{
@@ -1468,7 +1622,7 @@ public:
// Update the party identification.
SessionOwnerIdPtr test = new SessionOwnerId();
- SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
if (search != mImplPriv->mSessionCookies.end())
{
// Set the ConnectedLine information on the other controller.
@@ -1840,7 +1994,7 @@ public:
lg(Debug) << "Executing a GetCookie operation";
CookiePtr test = new CookieType();
- SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator search = mImplPriv->mSessionCookies.find(test->ice_id());
if (search == mImplPriv->mSessionCookies.end())
{
@@ -1979,28 +2133,68 @@ void SipSession::removeCookies(const AsteriskSCF::SessionCommunications::V1::Ses
}
/**
- * An implementation of the getCookies method as defined in SessionCommunications.ice which gets specific cookies
- * from the session.
+ * Get the specified cookies from the session and pass it to
+ * the given AMD callback handle.
+ *
+ * @param cb The AMD callback reference.
+ * @param cookieTypes The cookies to get.
+ * @param sessionPriv The session for whom the information is requested from.
*/
-AsteriskSCF::SessionCommunications::V1::SessionCookies SipSession::getCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes, const Ice::Current&)
+class GetCookiesOperation : public SuspendableWork
{
- AsteriskSCF::SessionCommunications::V1::SessionCookies cookies;
-
- for (AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i = cookieTypes.begin();
- i != cookieTypes.end();
- ++i)
+public:
+ /**
+ * @param cb The callback handle for the AMD operation that requested the information.
+ * @param session The session for whom the information is requested from.
+ */
+ GetCookiesOperation(const AsteriskSCF::SessionCommunications::V1::AMD_Session_getCookiesPtr& cb,
+ const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes,
+ const SipSessionPrivPtr& sessionPriv)
+ : mCb(cb), mCookieTypes(cookieTypes), mImplPriv(sessionPriv)
{
- AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator cookie = mImplPriv->mSessionCookies.find((*i)->ice_id());
+ }
- if (cookie == mImplPriv->mSessionCookies.end())
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
{
- continue;
- }
+ lg(Debug) << "Executing a GetCookies operation";
+
+ AsteriskSCF::SessionCommunications::V1::SessionCookies results;
+
+ for (AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i = mCookieTypes.begin();
+ i != mCookieTypes.end(); ++i)
+ {
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator foundItem =
+ mImplPriv->mSessionCookies.find((*i)->ice_id());
- cookies.push_back(cookie->second);
+ if (foundItem == mImplPriv->mSessionCookies.end())
+ {
+ continue;
+ }
+
+ results.push_back(foundItem->second);
+ }
+
+ mCb->ice_response(results);
+
+ return Complete;
}
- return cookies;
+private:
+ AsteriskSCF::SessionCommunications::V1::AMD_Session_getCookiesPtr mCb;
+ AsteriskSCF::SessionCommunications::V1::SessionCookies mCookieTypes;
+ SipSessionPrivPtr mImplPriv;
+};
+
+/**
+ * An implementation of the getCookies method as defined in SessionCommunications.ice which gets specific cookies
+ * from the session.
+ */
+void SipSession::getCookies_async(
+ const ::AsteriskSCF::SessionCommunications::V1::AMD_Session_getCookiesPtr&cb,
+ const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes,
+ const Ice::Current&)
+{
+ enqueueSessionWork(new GetCookiesOperation(cb, cookieTypes, mImplPriv));
}
/**
diff --git a/src/SipSession.h b/src/SipSession.h
index cb501f1..788e736 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -211,8 +211,11 @@ public:
* Used during replication
*/
void setCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookieDict&);
- void removeCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current& );
- AsteriskSCF::SessionCommunications::V1::SessionCookies getCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&);
+ void removeCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&);
+ void getCookies_async(
+ const ::AsteriskSCF::SessionCommunications::V1::AMD_Session_getCookiesPtr&,
+ const AsteriskSCF::SessionCommunications::V1::SessionCookies&,
+ const Ice::Current&);
AsteriskSCF::SessionCommunications::V1::SessionCookies getCookies();
AsteriskSCF::SessionCommunications::V1::SessionCookieDict getAllCookies();
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list