[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 24 16:57:57 CDT 2010
branch "master" has been updated
via 38117850f8413ab7b94295797c6e8c99e5e994a2 (commit)
via ef6c994661e7dc79206649b6b34ef7ca38c03854 (commit)
from 6a87050f90ee2f66f772f11d01ced07deecd7342 (commit)
Summary of changes:
src/SipEndpoint.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++------
src/SipEndpoint.h | 2 +
2 files changed, 70 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit 38117850f8413ab7b94295797c6e8c99e5e994a2
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Aug 24 19:09:43 2010 -0300
Add preliminary SDP creation. Next up will be the media work so we can actually get an IP address and port to populate the SDP with.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index d1b6b79..3da06c5 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -26,11 +26,11 @@ public:
return false;
}
- // TODO: Produce SDP to attach to the outgoing INVITE
+ pjmedia_sdp_session *sdp = mEndpoint->createSDPOffer();
// Create an INVITE session
pjsip_inv_session *inviteSession;
- if ((pjsip_inv_create_uac(dialog, NULL, 0, &inviteSession)) != PJ_SUCCESS)
+ if ((pjsip_inv_create_uac(dialog, sdp, 0, &inviteSession)) != PJ_SUCCESS)
{
pjsip_dlg_terminate(dialog);
return false;
@@ -88,10 +88,9 @@ public:
}
void connected(const Core::Endpoint::V1::EndpointIdPtr& ep, const Ice::Current&)
{
- // TODO: Produce SDP to fill in here
-
+ pjmedia_sdp_session *sdp = mEndpoint->createSDPOffer();
pjsip_tx_data *packet;
- if ((pjsip_inv_answer(mEndpoint->getInviteSession(), 200, NULL, NULL, &packet)) == PJ_SUCCESS)
+ if ((pjsip_inv_answer(mEndpoint->getInviteSession(), 200, NULL, sdp, &packet)) == PJ_SUCCESS)
{
pjsip_inv_send_msg(mEndpoint->getInviteSession(), packet);
}
@@ -149,10 +148,9 @@ public:
}
void progress(const Core::Endpoint::V1::EndpointIdPtr& ep, const Hydra::Session::V1::ResponseCodePtr& response, const Ice::Current&)
{
- // TODO: Produce SDP to pass in here
-
+ pjmedia_sdp_session *sdp = mEndpoint->createSDPOffer();
pjsip_tx_data *packet;
- if ((pjsip_inv_answer(mEndpoint->getInviteSession(), 183, NULL, NULL, &packet)) == PJ_SUCCESS)
+ if ((pjsip_inv_answer(mEndpoint->getInviteSession(), 183, NULL, sdp, &packet)) == PJ_SUCCESS)
{
pjsip_inv_send_msg(mEndpoint->getInviteSession(), packet);
}
@@ -226,5 +224,67 @@ void SipEndpoint::destroy()
mEndpointFactory->remove(this);
}
+/**
+ * Internal function called to produce an SDP session structure.
+ */
+pjmedia_sdp_session *SipEndpoint::createSDPOffer()
+{
+ pjmedia_sdp_session *sdp = static_cast<pjmedia_sdp_session*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_session)));
+
+ char user[] = "AsteriskSCF";
+ sdp->origin.user = pj_str(user);
+ sdp->origin.version = 0;
+ char net_type[] = "IN";
+ sdp->origin.net_type = pj_str(net_type);
+ char addr_type[] = "IPV4";
+ sdp->origin.addr_type = pj_str(addr_type);
+ sdp->name = pj_str(user);
+ sdp->time.start = 0;
+ sdp->time.stop = 0;
+ sdp->attr_count = 0;
+
+ // Add connection details at the session level since we currently only support one media stream.
+ sdp->conn = static_cast<pjmedia_sdp_conn*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_conn)));
+ sdp->conn->net_type = pj_str(net_type);
+ sdp->conn->addr_type = pj_str(addr_type);
+ // Populate sdp->conn->addr here with the local address
+
+ // Add a single media stream
+ sdp->media_count = 1;
+ sdp->media[0] = static_cast<pjmedia_sdp_media*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_media)));
+ char desc_media[] = "audio";
+ sdp->media[0]->desc.media = pj_str(desc_media);
+ // Populate sdp->media[0]->desc.port with the local port
+ // Set sdp->media[0]->desc.port_count to 1 for one port
+ char desc_transport[] = "RTP/AVP";
+ sdp->media[0]->desc.transport = pj_str(desc_transport);
+
+ // Populate the stream with codec details
+ sdp->media[0]->desc.fmt_count = 0;
+ sdp->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
+ char pt[] = "0";
+ rtpmap.pt = pj_str(pt);
+ rtpmap.clock_rate = 8000;
+ char enc_name[] = "PCMU";
+ rtpmap.enc_name = pj_str(enc_name);
+ rtpmap.param.slen = 0;
+ pjmedia_sdp_rtpmap_to_attr(mDialog->pool, &rtpmap, &attr);
+ sdp->media[0]->attr[sdp->media[0]->attr_count++] = attr;
+
+ // Might as well add sendrecv
+ attr = static_cast<pjmedia_sdp_attr*>(pj_pool_zalloc(mDialog->pool, sizeof(pjmedia_sdp_attr)));
+ char sendrecv[] = "sendrecv";
+ attr->name = pj_str(sendrecv);
+ sdp->media[0]->attr[sdp->media[0]->attr_count++] = attr;
+
+ return sdp;
+}
+
}; // end SipChannelService
}; // end Hydra
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 1ad66fe..5427800 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -32,6 +32,8 @@ public:
void destroy();
+ pjmedia_sdp_session *createSDPOffer();
+
/**
* Internal function which sets the PJsip dialog.
*/
commit ef6c994661e7dc79206649b6b34ef7ca38c03854
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Aug 24 17:01:12 2010 -0300
Remove a TODO item that has been done.
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 0252362..d1b6b79 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -53,7 +53,6 @@ public:
// Boom! Houston, we have transmission.
pjsip_inv_send_msg(inviteSession, packet);
- // TODO: Store the signal callback pointer so that results of this outgoing leg can be interpreted and reflected
return true;
}
void terminate(const Core::Endpoint::V1::EndpointIdPtr& caller, const Ice::Current&)
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list