[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "sessioncontroller" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Sun Jul 3 13:56:30 CDT 2011
branch "sessioncontroller" has been updated
via 647ba356cd9c781455efa7be32f84a5facb16869 (commit)
from 6c48d6510c1103531fb0aa6abd40f7c7645bd6b6 (commit)
Summary of changes:
src/SipSession.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 100 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit 647ba356cd9c781455efa7be32f84a5facb16869
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jul 3 15:56:27 2011 -0300
Add support for allowing the session controller to add streams to a session.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 695c1a7..0e2ca30 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -282,9 +282,20 @@ public:
StreamInformationDict mStreams;
/**
+ * Newly added streams that are awaiting a response from the remote party on acceptance.
+ */
+ StreamInformationDict mNewStreams;
+
+ /**
* A proxy to the SessionController we are controlling.
*/
AsteriskSCF::SessionCommunications::V1::SessionControllerPrx mSessionController;
+
+ /**
+ * A pointer to the callback class used to send a response to the SessionController with which streams
+ * have been added.
+ */
+ AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr mAddStreamsCb;
};
/**
@@ -300,9 +311,10 @@ class ChangeStreamStatesOperation : public SuspendableWork
{
public:
ChangeStreamStatesOperation(
+ const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_changeStreamStatesPtr& cb,
const AsteriskSCF::Media::V1::StreamStateDict& streams,
const boost::shared_ptr<SipSessionPriv>& sessionPriv)
- : mStreams(streams), mImplPriv(sessionPriv) { }
+ : mCb(cb), mStreams(streams), mImplPriv(sessionPriv) { }
SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
{
@@ -395,23 +407,78 @@ public:
pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
}
}
+
+ mCb->ice_response();
return Complete;
}
private:
+ AsteriskSCF::SessionCommunications::V1::AMD_SessionController_changeStreamStatesPtr mCb;
AsteriskSCF::Media::V1::StreamStateDict mStreams;
boost::shared_ptr<SipSessionPriv> mImplPriv;
};
+class AddStreamsOperation : public SuspendableWork
+{
+public:
+ AddStreamsOperation(
+ const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr& cb,
+ const AsteriskSCF::Media::V1::StreamInformationDict& streams,
+ const boost::shared_ptr<SipSessionPriv>& sessionPriv,
+ const SipSessionPtr& session)
+ : mCb(cb), mStreams(streams), mImplPriv(sessionPriv), mSession(session) { }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ lg(Debug) << "Executing an addStreams Operation";
+
+ // If there is an outstanding transaction then no streams can be added at this time
+ if (mImplPriv->mInviteSession->invite_tsx)
+ {
+ mCb->ice_response(StreamInformationDict());
+ return Complete;
+ }
+
+ // Create an offer adding in the requested streams
+ pjmedia_sdp_session *sdp = mSession->createSDPOffer(mStreams);
+
+ // Store callback information so when the remote party responds with which streams were accepted we can
+ // communicate it to the controller
+ mImplPriv->mAddStreamsCb = mCb;
+
+ // Okay, create and send the reinvite!
+ pjsip_tx_data *packet = NULL;
+
+ if ((pjsip_inv_reinvite(mImplPriv->mInviteSession, NULL, mImplPriv->mSDP, &packet)) == PJ_SUCCESS)
+ {
+ pjsip_inv_send_msg(mImplPriv->mInviteSession, packet);
+ }
+ else
+ {
+ // If we couldn't create the reinvite no streams were added
+ mCb->ice_response(StreamInformationDict());
+ }
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr mCb;
+ AsteriskSCF::Media::V1::StreamInformationDict mStreams;
+ boost::shared_ptr<SipSessionPriv> mImplPriv;
+ SipSessionPtr mSession;
+};
+
class RemoveStreamsOperation : public SuspendableWork
{
public:
RemoveStreamsOperation(
+ const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_removeStreamsPtr& cb,
const AsteriskSCF::Media::V1::StreamInformationDict& streams,
const boost::shared_ptr<SipSessionPriv>& sessionPriv,
const SipSessionPtr& session)
- : mStreams(streams), mImplPriv(sessionPriv), mSession(session) { }
+ : mCb(cb), mStreams(streams), mImplPriv(sessionPriv), mSession(session) { }
SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
{
@@ -434,10 +501,13 @@ public:
pjsip_inv_set_sdp_answer(mImplPriv->mInviteSession, sdp);
}
+ mCb->ice_response();
+
return Complete;
}
private:
+ AsteriskSCF::SessionCommunications::V1::AMD_SessionController_removeStreamsPtr mCb;
AsteriskSCF::Media::V1::StreamInformationDict mStreams;
boost::shared_ptr<SipSessionPriv> mImplPriv;
SipSessionPtr mSession;
@@ -452,20 +522,25 @@ public:
SipSessionController(boost::shared_ptr<SipSessionPriv> implPriv, const SipSessionPtr& session) :
mImplPriv(implPriv), mSession(session) { }
- void changeStreamStates(const AsteriskSCF::Media::V1::StreamStateDict& states, const Ice::Current&)
+ void changeStreamStates_async(const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_changeStreamStatesPtr& cb,
+ const AsteriskSCF::Media::V1::StreamStateDict& states, const Ice::Current&)
{
lg(Debug) << "Queueing changeStreamStates operation";
- mSession->enqueueSessionWork(new ChangeStreamStatesOperation(states, mImplPriv));
+ mSession->enqueueSessionWork(new ChangeStreamStatesOperation(cb, states, mImplPriv));
}
- AsteriskSCF::Media::V1::StreamInformationDict addStreams(const AsteriskSCF::Media::V1::StreamInformationDict&, const Ice::Current&)
+ void addStreams_async(const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_addStreamsPtr& cb,
+ const AsteriskSCF::Media::V1::StreamInformationDict& streams, const Ice::Current&)
{
+ lg(Debug) << "Queueing addStreams operation";
+ mSession->enqueueSessionWork(new AddStreamsOperation(cb, streams, mImplPriv, mSession));
}
- void removeStreams(const AsteriskSCF::Media::V1::StreamInformationDict& streams, const Ice::Current&)
+ void removeStreams_async(const AsteriskSCF::SessionCommunications::V1::AMD_SessionController_removeStreamsPtr& cb,
+ const AsteriskSCF::Media::V1::StreamInformationDict& streams, const Ice::Current&)
{
lg(Debug) << "Queueing removeStreams operation";
- mSession->enqueueSessionWork(new RemoveStreamsOperation(streams, mImplPriv, mSession));
+ mSession->enqueueSessionWork(new RemoveStreamsOperation(cb, streams, mImplPriv, mSession));
}
private:
@@ -1605,6 +1680,9 @@ pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::St
// Push the payload mapping to the RTP session so it'll correctly map things
session->associatePayloads(payloads);
+ // Since this is a newly added stream record it as such until the remote party accepts or declines it
+ mImplPriv->mNewStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count), stream->second));
+
// Now that all is done we can add this stream in
mImplPriv->mStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count++), stream->second));
}
@@ -1627,6 +1705,9 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
// Get the non-stream level connection information in case there is no connection level one
std::string destination(pj_strbuf(&offer->conn->addr), pj_strlen(&offer->conn->addr));
+ // A dictionary containing streams that have been added to the session
+ StreamInformationDict streamsAdded;
+
// A dictionary containing streams that have been removed from the session
StreamInformationDict streamsRemoved;
@@ -1660,6 +1741,12 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
continue;
}
+ // If this is a newly added stream we may need to notify a session controller that it was accepted
+ if (mImplPriv->mNewStreams.find(boost::lexical_cast<std::string>(stream)) != mImplPriv->mNewStreams.end())
+ {
+ streamsAdded.insert(make_pair(boost::lexical_cast<std::string>(stream), ourStream));
+ }
+
// If a format is actually found we add it to this sequence so we can create an RTP session
FormatSeq formats;
@@ -1915,6 +2002,12 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
}
}
+ if (!streamsAdded.empty() && mImplPriv->mAddStreamsCb)
+ {
+ mImplPriv->mAddStreamsCb->ice_response(streamsAdded);
+ mImplPriv->mAddStreamsCb = 0;
+ }
+
return mImplPriv->mSDP;
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list