[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "media" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Jun 15 08:08:13 CDT 2011
branch "media" has been updated
via 8fc35f40989061e6473806b993b3b623319a05b8 (commit)
from 6eaf8baaf0ea97d672be92367676bf42b3cd450b (commit)
Summary of changes:
src/PJSipSessionModule.cpp | 127 +++++++++++++-------------------------------
src/SipSession.cpp | 22 ++------
src/SipSession.h | 2 -
3 files changed, 42 insertions(+), 109 deletions(-)
- Log -----------------------------------------------------------------
commit 8fc35f40989061e6473806b993b3b623319a05b8
Author: Joshua Colp <jcolp at digium.com>
Date: Wed Jun 15 10:08:16 2011 -0300
Add support for updating stream information when it changes. Right now the only thing supported
is the IP address/port to send the media to. Next up is fixing up replication a bit and then properly
handling cases where negotiation fails either due to the remote side or our configuraton.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index b688250..10dca3a 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -27,6 +27,8 @@
#include <AsteriskSCF/Core/Routing/RoutingIf.h>
#include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
#include <AsteriskSCF/Media/MediaIf.h>
+#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
#include <AsteriskSCF/logger.h>
#include <AsteriskSCF/WorkQueue/WorkQueue.h>
#include <AsteriskSCF/WorkQueue/SuspendableWorkQueue.h>
@@ -53,6 +55,8 @@ using namespace AsteriskSCF::Core::Routing::V1;
using namespace AsteriskSCF::Core::Endpoint::V1;
using namespace AsteriskSCF::SessionCommunications::V1;
using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Media::RTP::V1;
+using namespace AsteriskSCF::Media::SDP::V1;
using namespace AsteriskSCF::SIP::V1;
using namespace AsteriskSCF::System::ThreadPool::V1;
using namespace AsteriskSCF::System::WorkQueue::V1;
@@ -1417,111 +1421,56 @@ protected:
return Complete;
}
-#if 0
- const pjmedia_sdp_conn *remote_conn = remote_sdp->media[0]->conn ? remote_sdp->media[0]->conn : remote_sdp->conn;
-
PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)mInv->mod_data[mModuleId];
SipSessionPtr session = session_mod_info->getSessionPtr();
- std::string destination(pj_strbuf(&remote_conn->addr), pj_strlen(&remote_conn->addr));
- try
- {
- session->setRemoteDetails(destination, remote_sdp->media[0]->desc.port);
- }
- catch (const AsteriskSCF::Media::RTP::V1::InvalidAddress&)
- {
- pjsip_tx_data *packet;
- if (pjsip_inv_end_session(mInv, 488, NULL, &packet) == PJ_SUCCESS)
- {
- pjsip_inv_send_msg(mInv, packet);
- }
- return Complete;
- }
+ // In case there is no stream level connection details store this away
+ std::string destination(pj_strbuf(&remote_sdp->conn->addr), pj_strlen(&remote_sdp->conn->addr));
+
+ StreamSinkSeq sinks = session->getSinks();
// Each stream has its own set of formats, so go to that granularity
for (unsigned int stream = 0; stream < remote_sdp->media_count; stream++)
{
- // We should have the parsing of the connection information here
-
- // We should have the parsing of the rtcp attribute here
-
- FormatSeq formats;
-
- // Next step is to see what formats exist on this stream
- for (unsigned int format = 0; format < remote_sdp->media[stream]->desc.fmt_count; format++)
+ // Do some sanity checking to confirm we have a stream setup for their answer stream
+ if (sinks.size() < (stream + 1))
{
- FormatDiscoverySDPPtr params = new FormatDiscoverySDP();
- params->category = "media_format";
- std::stringstream(pj_strbuf(&remote_sdp->media[stream]->desc.fmt[format])) >> params->payload;
- params->type = std::string(pj_strbuf(&remote_sdp->media[stream]->desc.media),
- pj_strlen(&remote_sdp->media[stream]->desc.media));
-
- // Some devices rely solely on the payload for known formats (such as PCMU) so the following format
- // parameters are optional
- const pjmedia_sdp_attr *attr;
- if ((attr = pjmedia_sdp_media_find_attr2(remote_sdp->media[stream], "rtpmap",
- &remote_sdp->media[stream]->desc.fmt[format])))
- {
- pjmedia_sdp_rtpmap *rtpmap;
- if ((pjmedia_sdp_attr_to_rtpmap(mInv->pool_active, attr, &rtpmap)) == PJ_SUCCESS)
- {
- params->subtype = std::string(pj_strbuf(&rtpmap->enc_name), pj_strlen(&rtpmap->enc_name));
- params->samplerate = rtpmap->clock_rate;
- }
- }
-
- // Next we move on to the format specific parameters
- if ((attr = pjmedia_sdp_media_find_attr2(remote_sdp->media[stream], "fmtp",
- &remote_sdp->media[stream]->desc.fmt[format])))
- {
- pjmedia_sdp_fmtp fmtp;
- if ((pjmedia_sdp_attr_get_fmtp(attr, &fmtp)) == PJ_SUCCESS)
- {
- std::string parameter = std::string(pj_strbuf(&fmtp.fmt_param), pj_strlen(&fmtp.fmt_param));
- params->parameters.push_back(parameter);
- }
- }
+ continue;
+ }
- // Next up are attributes that are not specific to the format, such as ptime
- for (unsigned int attribute = 0; attribute < remote_sdp->media[stream]->attr_count; attribute++)
- {
- // Attributes we already touch above OR know aren't helpful to the media format component don't need to
- // be given to it, obviously
- if (!pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "rtpmap") ||
- !pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "fmtp") ||
- !pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "rtcp") ||
- !pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "sendrecv") ||
- !pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "sendonly") ||
- !pj_strcmp2(&remote_sdp->media[stream]->attr[attribute]->name, "recvonly"))
- {
- continue;
- }
+ // Assume no stream level details until proven otherwise
+ std::string connection = destination;
+ if (remote_sdp->media[stream]->conn)
+ {
+ connection = std::string(pj_strbuf(&remote_sdp->media[stream]->conn->addr),
+ pj_strlen(&remote_sdp->media[stream]->conn->addr));
+ }
- std::string parameter = std::string(pj_strbuf(&remote_sdp->media[stream]->attr[attribute]->name),
- pj_strlen(&remote_sdp->media[stream]->attr[attribute]->name)) + ':' +
- std::string(pj_strbuf(&remote_sdp->media[stream]->attr[attribute]->value),
- pj_strlen(&remote_sdp->media[stream]->attr[attribute]->value));
- params->parameters.push_back(parameter);
- }
+ // TODO: Add parsing of RTCP attribute
- try
- {
- MediaFormatServicePrx service = MediaFormatServicePrx::uncheckedCast(mServiceLocator->locate(params));
+ // The order of the media lines should match our offer so we can get the sink to update
+ // connection details on based on what stream number this is, easy!
+ StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks[stream]);
- // It is entirely possible for the service locator to not find a service that knows about this media
- // format
- if (service != 0)
- {
- formats.push_back(FormatPtr::dynamicCast(service->getFormat(params)));
- }
- }
- catch (...)
+ // If this throws an exception then they answered with an address that is incompatible
+ // for the session, so we abort since our relationship with the other side seems to be
+ // broken
+ try
+ {
+ sink->setRemoteDetails(connection, remote_sdp->media[stream]->desc.port);
+ }
+ catch (const InvalidAddress&)
+ {
+ pjsip_tx_data *packet;
+ if (pjsip_inv_end_session(mInv, 488, NULL, &packet) == PJ_SUCCESS)
{
- // If we get here the format just isn't supported...
+ pjsip_inv_send_msg(mInv, packet);
}
+ return Complete;
}
+
+ // TODO: Add format parsing stuff here so we can determine the formats actually negotiated
}
-#endif
return Complete;
}
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 9817394..2f4fbe6 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1019,7 +1019,6 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
// If none exist we can't provide the stream
if (factory == 0)
{
- std::cout << "No factory for what we need" << std::endl;
continue;
}
@@ -1029,7 +1028,6 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
// Double check to make sure they actually gave us a sesson back... they could have had a problem
if (session == 0)
{
- std::cout << "No session created" << std::endl;
continue;
}
@@ -1086,12 +1084,6 @@ pjmedia_sdp_session *SipSession::createSDPOffer()
session->associatePayloads(payloads);
}
- char createdSDP[1024] = "";
-
- pjmedia_sdp_print(mImplPriv->mSDP, createdSDP, sizeof(createdSDP));
-
- std::cout << createdSDP << std::endl;
-
return mImplPriv->mSDP;
}
@@ -1302,16 +1294,6 @@ pjmedia_sdp_session *SipSession::createSDPAnswer(const pjmedia_sdp_session* offe
}
/**
- * Internal function called to set the remote details for RTP.
- */
-void SipSession::setRemoteDetails(const std::string& destination, int port)
-{
- AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx sink =
- AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx::uncheckedCast(mImplPriv->mSinks.front());
- sink->setRemoteDetails(destination, port);
-}
-
-/**
* Internal function which sets the PJsip dialog.
*/
void SipSession::setDialog(pjsip_dialog *dialog)
@@ -1418,6 +1400,10 @@ void SipSession::setListeners(const AsteriskSCF::SIP::V1::SessionListenerSeq& li
*/
AsteriskSCF::Media::V1::SessionPrx SipSession::getHiddenMediaSession()
{
+ if (mImplPriv->mRTPSessions.empty())
+ {
+ return 0;
+ }
// TODO: This should return a sequence
return mImplPriv->mRTPSessions.front();
}
diff --git a/src/SipSession.h b/src/SipSession.h
index 2ca987b..4fe6c50 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -171,8 +171,6 @@ public:
pjmedia_sdp_session *createSDPAnswer(const pjmedia_sdp_session*);
- void setRemoteDetails(const std::string&, int);
-
void setDialog(pjsip_dialog *dialog);
pjsip_dialog *getDialog();
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list