[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:20:02 CDT 2011
branch "sessioncontroller" has been updated
via 6c48d6510c1103531fb0aa6abd40f7c7645bd6b6 (commit)
via e94db9d2c0f27dcda914cab361250bad3ec8c74d (commit)
from 44bf3fc63cd258cb15dc572727686e13de8d0c83 (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 2 +-
src/SipEndpoint.cpp | 14 ++++----
src/SipEndpoint.h | 8 +----
src/SipSession.cpp | 74 +++++++++++++++++++-------------------------
src/SipSession.h | 2 +-
5 files changed, 42 insertions(+), 58 deletions(-)
- Log -----------------------------------------------------------------
commit 6c48d6510c1103531fb0aa6abd40f7c7645bd6b6
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jul 3 15:19:32 2011 -0300
Add the ability to specify streams that should be added to the SDP when creating an offer. This is cumulative, so if streams need to be removed modifySDP must also be called afterwards.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 59c0c9a..1334ca7 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -378,7 +378,7 @@ protected:
if (!mInv->neg || (pjmedia_sdp_neg_get_neg_remote(mInv->neg, &remote_sdp) != PJ_SUCCESS))
{
// No SDP was present in the INVITE so we need to create an offer
- sdp = mSession->createSDPOffer();
+ sdp = mSession->createSDPOffer(StreamInformationDict());
}
else
{
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 0d44513..67f753f 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -431,9 +431,9 @@ SDPDescriptorPtr SipEndpoint::getDescriptor(const FormatPtr& format)
return 0;
}
-StreamTopologyMap SipEndpoint::getStreamTopology()
+StreamInformationDict SipEndpoint::getStreamTopology()
{
- StreamTopologyMap topology;
+ StreamInformationDict topology;
// Iterate through all the configured formats placing the same types on the same stream
for (std::vector<ConfiguredFormatPtr>::const_iterator configuredFormat = mImplPriv->mFormats.begin();
@@ -441,19 +441,19 @@ StreamTopologyMap SipEndpoint::getStreamTopology()
++configuredFormat)
{
// See if a stream already exists for this type
- StreamTopologyMap::iterator stream = topology.find((*configuredFormat)->getDescriptor()->type);
+ StreamInformationDict::iterator stream = topology.find((*configuredFormat)->getDescriptor()->type);
if (stream == topology.end())
{
// If one does not exist we have to create it and add it to the map
- FormatSeq formats;
- formats.push_back((*configuredFormat)->getFormat());
- topology.insert(make_pair((*configuredFormat)->getDescriptor()->type, formats));
+ StreamInformationPtr newStream = new StreamInformation();
+ newStream->formats.push_back((*configuredFormat)->getFormat());
+ topology.insert(make_pair((*configuredFormat)->getDescriptor()->type, newStream));
}
else
{
// If one does exist we can simply add the format to it
- stream->second.push_back((*configuredFormat)->getFormat());
+ stream->second->formats.push_back((*configuredFormat)->getFormat());
}
}
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index b5b7e02..b92127f 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -205,12 +205,6 @@ private:
};
/**
- * A type def for a sequence of stream topology entries, each entry represents a stream and the contents are the formats
- * carried over the stream.
- */
-typedef std::map<std::string, AsteriskSCF::Media::V1::FormatSeq> StreamTopologyMap;
-
-/**
* Private implementation details for SipEndpoint.
*/
class SipEndpointImplPriv;
@@ -277,7 +271,7 @@ public:
/**
* API call which returns the stream topology to be used for an SDP offer.
*/
- StreamTopologyMap getStreamTopology();
+ AsteriskSCF::Media::V1::StreamInformationDict getStreamTopology();
private:
/**
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index fb50f72..695c1a7 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -95,7 +95,7 @@ public:
const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
: mAdapter(adapter), mDialog(0), mInviteSession(0), mEndpoint(endpoint), mDestination(destination),
- mManager(manager), mServiceLocator(serviceLocator), mReplica(replica), mSDP(0), mSDPFinalized(false) { };
+ mManager(manager), mServiceLocator(serviceLocator), mReplica(replica), mSDP(0) { };
AsteriskSCF::SessionCommunications::V1::SessionInfoPtr getInfo()
{
@@ -277,11 +277,6 @@ public:
pjmedia_sdp_session *mSDP;
/**
- * Whether the SDP has been finalized or not.
- */
- bool mSDPFinalized;
-
- /**
* Streams present on the session.
*/
StreamInformationDict mStreams;
@@ -526,7 +521,7 @@ void SipSession::initializePJSIPStructs()
pjsip_inv_session *inviteSession;
// Create an SDP offer based on what is configured
- pjmedia_sdp_session *sdp = createSDPOffer();
+ pjmedia_sdp_session *sdp = createSDPOffer(StreamInformationDict());
if ((pjsip_inv_create_uac(dialog, sdp, 0, &inviteSession)) != PJ_SUCCESS)
{
@@ -1500,21 +1495,20 @@ void SipSession::addFormatstoSDP(const FormatSeq& formats, pjmedia_sdp_media *me
}
/**
- * Internal function called to produce an SDP session structure using configuration.
+ * Internal function called to produce an SDP session structure using configuration and provided streams
*/
-pjmedia_sdp_session *SipSession::createSDPOffer()
+pjmedia_sdp_session *SipSession::createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict& streams)
{
- // If SDP has already been produced then just return it, don't recreate it
- if (mImplPriv->mSDPFinalized == true)
+ StreamInformationDict requestedStreams = streams;
+
+ // If no streams have been provided use a generate topology from the endpoint based on configured formats
+ if (requestedStreams.empty())
{
- return mImplPriv->mSDP;
+ requestedStreams = mImplPriv->mEndpoint->getStreamTopology();
}
- // Retrieve the stream topology from the endpoint
- StreamTopologyMap streams = mImplPriv->mEndpoint->getStreamTopology();
-
- // If there are no streams then we can not create an SDP offer
- if (streams.empty())
+ // If we still have no streams we can not produce an SDP as it would be broken
+ if (requestedStreams.empty())
{
return 0;
}
@@ -1525,16 +1519,14 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
mImplPriv->mSDP = createSDP();
}
- int streamNum = 0;
-
- // Iterate through each stream present in the topology
- for (StreamTopologyMap::const_iterator stream = streams.begin();
- stream != streams.end();
+ // Iterate through each requested stream
+ for (StreamInformationDict::const_iterator stream = requestedStreams.begin();
+ stream != requestedStreams.end();
++stream)
{
RTPServiceLocatorParamsPtr params = new RTPServiceLocatorParams();
params->category = "rtp";
- params->formats = stream->second;
+ params->formats = stream->second->formats;
params->ipv6 = mImplPriv->mEndpoint->getConfig().sessionConfig.rtpOverIPv6;
// Try to find a factory for RTP sessions matching what we need
@@ -1555,33 +1547,28 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
continue;
}
- // Instantiate a stream information class to contain details about this stream
- StreamInformationPtr ourStream = new StreamInformation();
-
- // Formats we already have so just copy them
- ourStream->formats = stream->second;
-
- // You might notice we do not set the state of the stream, this is because by default it is already
- // set to be send and receive.
-
// RTP sessions should only provide a single sink, so grab it and update the connection details with that
// of the remote party
StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(session->getSinks().front());
mImplPriv->mSinks.push_back(sink);
- ourStream->sinks.push_back(sink);
+ stream->second->sinks.push_back(sink);
// Ditto goes for source
StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(session->getSources().front());
mImplPriv->mSources.push_back(source);
- ourStream->sources.push_back(source);
+ stream->second->sources.push_back(source);
// Update the SIP session with some RTP session details
mImplPriv->mRTPSessions.push_back(session);
// Add the stream to the SDP
pjmedia_sdp_media *media = allocate_from_pool<pjmedia_sdp_media>(mImplPriv->mDialog->pool);
- mImplPriv->mSDP->media[mImplPriv->mSDP->media_count++] = media;
- pj_strdup2(mImplPriv->mDialog->pool, &media->desc.media, mImplPriv->mEndpoint->getDescriptor(stream->second.front())->type.c_str());
+
+ // The media count is purposely not incremented here since it is done when the stream is added to the sequence
+ // of streams
+ mImplPriv->mSDP->media[mImplPriv->mSDP->media_count] = media;
+ pj_strdup2(mImplPriv->mDialog->pool, &media->desc.media, mImplPriv->mEndpoint->getDescriptor(
+ stream->second->formats.front())->type.c_str());
// TODO: This should not be hardcoded
pj_strdup2(mImplPriv->mDialog->pool, &media->desc.transport, "RTP/AVP");
@@ -1613,19 +1600,16 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
PayloadMap payloads;
// Add all of the formats to the SDP
- addFormatstoSDP(stream->second, media, payloads);
+ addFormatstoSDP(stream->second->formats, media, payloads);
// Push the payload mapping to the RTP session so it'll correctly map things
session->associatePayloads(payloads);
- // The SDP has been finalized enough
- mImplPriv->mSDPFinalized = true;
-
// Now that all is done we can add this stream in
- mImplPriv->mStreams.insert(make_pair(boost::lexical_cast<std::string>(streamNum++), ourStream));
+ mImplPriv->mStreams.insert(make_pair(boost::lexical_cast<std::string>(mImplPriv->mSDP->media_count++), stream->second));
}
- return mImplPriv->mSDPFinalized == true ? mImplPriv->mSDP : 0;
+ return mImplPriv->mSDP;
}
/**
diff --git a/src/SipSession.h b/src/SipSession.h
index b4b5c48..f82a369 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -188,7 +188,7 @@ public:
*/
void destroy();
- pjmedia_sdp_session *createSDPOffer();
+ pjmedia_sdp_session *createSDPOffer(const AsteriskSCF::Media::V1::StreamInformationDict&);
pjmedia_sdp_session *createSDPAnswer(const pjmedia_sdp_session*,
AsteriskSCF::Media::V1::StreamInformationDict&);
commit e94db9d2c0f27dcda914cab361250bad3ec8c74d
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jul 3 14:51:14 2011 -0300
Don't crash if called when SDP has not yet been created.
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 947ee72..fb50f72 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1939,6 +1939,12 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
*/
pjmedia_sdp_session *SipSession::modifySDP(const AsteriskSCF::Media::V1::StreamInformationDict& toRemove)
{
+ // In order to modify SDP you have to have SDP
+ if (!mImplPriv->mSDP)
+ {
+ return 0;
+ }
+
// Iterate through each stream to remove so we can change the port number and make it go bye bye
for (AsteriskSCF::Media::V1::StreamInformationDict::const_iterator stream = toRemove.begin();
stream != toRemove.end();
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list