[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "modular-transport-refactor" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Jul 6 09:27:24 CDT 2011
branch "modular-transport-refactor" has been updated
via c390e457852658e44db0d7652feb74ab036737ce (commit)
from 1dcbe3dd82f1be73b25948f13370b8bd58ab4ac3 (commit)
Summary of changes:
src/ICETransport.cpp | 140 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 129 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit c390e457852658e44db0d7652feb74ab036737ce
Author: Brent Eagles <beagles at digium.com>
Date: Tue Jul 5 11:58:00 2011 -0230
Rework offer processing lost in merge.
diff --git a/src/ICETransport.cpp b/src/ICETransport.cpp
index 16ab255..1a7d19d 100644
--- a/src/ICETransport.cpp
+++ b/src/ICETransport.cpp
@@ -57,7 +57,8 @@ public:
mId(id),
mShuttingDown(false),
mNATType(AsteriskSCF::System::NAT::V1::Unknown),
- mRole(UndefinedRole)
+ mRole(UndefinedRole),
+ mTransport(0)
{
}
@@ -80,13 +81,131 @@ public:
return mRole;
}
- CandidatePtr negotiate(const CandidateSeq&,
+ CandidatePtr negotiate(const string& hostname, Ice::Int port, const CandidateSeq& candidates,
const Ice::Current&)
{
//
- // TODO: implement.
+ // So how this works is we create a remote SDP and call pjmedia_transport_start() easy peasy. (Same deal
//
- return 0;
+ pjmedia_sdp_session* remoteSDPSession =
+ static_cast<pjmedia_sdp_session*>(pj_pool_zalloc(mEnv->memoryPool(), sizeof(pjmedia_sdp_session)));
+
+
+ //
+ // TODO: I think the ICE transport ignores a lot of this stuff, but I'm going to add it for the time
+ // being anyways.
+ //
+
+ //
+ // Missing details, user, id, version, net type?
+ //
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->name, "ASCFMEDIA");
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->origin.user, "");
+ AddressPtr remoteHost(new Address(hostname, port));
+
+ remoteSDPSession->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mEnv->memoryPool(), sizeof(pjmedia_sdp_conn)));
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->conn->net_type, "IN");
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->origin.net_type, "IN");
+
+ //
+ // TODO: Look at whether the members can point to the same memory without issues.
+ //
+ if (remoteHost->isIPV6())
+ {
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->origin.addr_type, "IP6");
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->conn->addr_type, "IP6");
+ }
+ else
+ {
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->origin.addr_type, "IP4");
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->conn->addr_type, "IP4");
+ }
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->origin.addr, remoteHost->address().c_str());
+ pj_strdup2(mEnv->memoryPool(), &remoteSDPSession->conn->addr, remoteHost->address().c_str());
+ remoteSDPSession->attr_count = 0;
+
+ //
+ // Cut n' paste from current SIP session manager... icky. TODO: sift through and see what of this
+ // can be discarded for this purpose.
+ //
+ remoteSDPSession->media_count = 1;
+ pjmedia_sdp_media* media =
+ static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mEnv->memoryPool(), sizeof(pjmedia_sdp_media)));
+ remoteSDPSession->media[0] = media;
+ pj_strdup2(mEnv->memoryPool(), &media->desc.media, "audio");
+ media->desc.port = (pj_uint16_t) port; // XXX --- this is not going to be correct here.. we don't actually have this!
+ media->desc.port_count = 1;
+ pj_strdup2(mEnv->memoryPool(), &media->desc.transport, "RTP/AVP");
+
+ // Populate the stream with codec details
+ remoteSDPSession->media[0]->desc.fmt_count = 1;
+ remoteSDPSession->media[0]->attr_count = 0;
+
+ // TODO: We should iterate over the formats to produce this instead of hardcoding
+ pjmedia_sdp_rtpmap rtpmap;
+ pjmedia_sdp_attr *attr;
+
+ // This is hardcoded value for ULAW for now
+ pj_strdup2(mEnv->memoryPool(), &media->desc.fmt[0], "0");
+ rtpmap.pt = media->desc.fmt[0];
+ rtpmap.clock_rate = 8000;
+ pj_strdup2(mEnv->memoryPool(), &rtpmap.enc_name, "PCMU");
+ rtpmap.param.slen = 0;
+ pjmedia_sdp_rtpmap_to_attr(mEnv->memoryPool(), &rtpmap, &attr);
+ remoteSDPSession->media[0]->attr[remoteSDPSession->media[0]->attr_count++] = attr;
+
+ // Might as well add sendrecv
+ attr = static_cast<pjmedia_sdp_attr*>(pj_pool_zalloc(mEnv->memoryPool(), sizeof(pjmedia_sdp_attr)));
+ pj_strdup2(mEnv->memoryPool(), &attr->name, "sendrecv");
+ remoteSDPSession->media[0]->attr[remoteSDPSession->media[0]->attr_count++] = attr;
+
+ //
+ // I was concerned about the fact that for a given SIP session, there might be multiple media
+ // streams and multiple candidates. I'm not sure that its actually too much of an issue even
+ // if multiple media types are muxed on a single ICE negotiated flow, but there will need to be
+ // some redesign to pull in the multiple media streams associated with the session. For the moment
+ // we will operation under the premise that we are dealing with a single media stream.
+ // TODO: the SIP session gateway contains similar code, but from the offer perspective. This stuff
+ // should be refactored into a pjproject utility library.
+ //
+ //
+ pjmedia_sdp_media* currentMedia = remoteSDPSession->media[0];
+ for (CandidateSeq::const_iterator i = candidates.begin(); i != candidates.end(); ++i)
+ {
+ CandidatePtr candidate = *i;
+ ostringstream os;
+ os << "candidate:" << candidate->foundation << ' ' << candidate->componentId << " UDP " <<
+ candidate->priority << ' ' << candidate->mappedAddress << ' ' << candidate->mappedPort << " typ ";
+ string hostType;
+ switch (candidate->type)
+ {
+ case Host:
+ hostType = "host";
+ break;
+ case ServerReflexive:
+ hostType = "srflx";
+ break;
+ case PeerReflexive:
+ hostType = "prflx";
+ break;
+ case Relayed:
+ hostType = "relay";
+ break;
+ }
+ os << hostType;
+ if (candidate->type != Host)
+ {
+ os << " raddr " << candidate->baseAddress << " rport " << candidate->basePort;
+ }
+ string t = os.str();
+ pj_str_t candidateStr = pj_str(const_cast<char*>(t.c_str()));
+ pjmedia_sdp_attr* newAttribute = pjmedia_sdp_attr_create(mEnv->memoryPool(),
+ "candidate", &candidateStr);
+ pjmedia_sdp_attr_add(¤tMedia->attr_count, currentMedia->attr, newAttribute);
+ }
+ pjmedia_sdp_session localSession;
+ pjmedia_transport_encode_sdp(mTransport, mEnv->memoryPool(), &localSession, 0, 0);
+ pjmedia_transport_media_start(mTransport, mEnv->memoryPool(), &localSession, remoteSDPSession, 0);
}
CandidateSeq getCandidates(const Ice::Current&)
@@ -104,6 +223,7 @@ public:
//
return;
}
+ mTransport = transport;
pjmedia_transport_info info;
pjmedia_transport_info_init(&info);
@@ -141,15 +261,12 @@ public:
// candidate structures, so what we have to do is get the SDP from
// the transport and convert what we find there to our Ice structures.
//
- pjmedia_sdp_session* sdpSession;
- //
- // TODO: We are setting the transport size at 1, but I'm not sure that will always be the case.
- //
- pjmedia_endpt_create_sdp(mEndpoint->endpoint(), mEnv->memoryPool(), 1, &info.sock_info, &sdpSession);
- for (size_t i = 0; i < sdpSession->media_count; ++i)
+ pjmedia_sdp_session sdpSession;
+ pjmedia_transport_encode_sdp(mTransport, mEnv->memoryPool(), &sdpSession, 0, 0);
+ for (size_t i = 0; i < sdpSession.media_count; ++i)
{
const string candidateName("candidate");
- pjmedia_sdp_media* media = sdpSession->media[i];
+ pjmedia_sdp_media* media = sdpSession.media[i];
for (size_t j = 0; j < media->attr_count; ++j)
{
pjmedia_sdp_attr* attr = media->attr[j];
@@ -329,6 +446,7 @@ private:
CandidateSeq mCandidates;
PJMediaEnvironmentPtr mEnv;
PJMediaEndpointPtr mEndpoint;
+ pjmedia_transport* mTransport;
void stateCheck()
{
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list