summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-03-29 21:54:21 +0000
committerBenny Prijono <bennylp@teluu.com>2007-03-29 21:54:21 +0000
commit3bde23647e94fe0764c8e32d53537e6b116e71de (patch)
tree7c8aa98ecff5193e7b89e6f44697b9f7538d59b3 /pjmedia
parent7d29fabefb6405ea7bc47b8d9a465df5af96612c (diff)
Added ICE-CONTROLLING and ICE-CONTROLLED STUN attribute types
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1114 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/include/pjmedia/rtp.h17
-rw-r--r--pjmedia/src/pjmedia/transport_ice.c31
2 files changed, 36 insertions, 12 deletions
diff --git a/pjmedia/include/pjmedia/rtp.h b/pjmedia/include/pjmedia/rtp.h
index 5b7b8e64..f41cda05 100644
--- a/pjmedia/include/pjmedia/rtp.h
+++ b/pjmedia/include/pjmedia/rtp.h
@@ -77,7 +77,8 @@ PJ_BEGIN_DECL
/**
- * RTP packet header.
+ * RTP packet header. Note that all RTP functions here will work with this
+ * header in network byte order.
*/
#pragma pack(1)
struct pjmedia_rtp_hdr
@@ -229,7 +230,7 @@ typedef struct pjmedia_rtp_status pjmedia_rtp_status;
*
* @param ses The session.
* @param default_pt Default payload type.
- * @param sender_ssrc SSRC used for outgoing packets.
+ * @param sender_ssrc SSRC used for outgoing packets, in host byte order.
*
* @return PJ_SUCCESS if successfull.
*/
@@ -262,11 +263,16 @@ PJ_DECL(pj_status_t) pjmedia_rtp_encode_rtp( pjmedia_rtp_session *ses,
* The decode function is guaranteed to point the payload to the correct
* position regardless of any options present in the RTP packet.
*
+ * Note that this function does not modify the returned RTP header to
+ * host byte order.
+ *
* @param ses The session.
* @param pkt The received RTP packet.
* @param pkt_len The length of the packet.
- * @param hdr Upon return will point to the location of the RTP header
- * inside the packet.
+ * @param hdr Upon return will point to the location of the RTP
+ * header inside the packet. Note that the RTP header
+ * will be given back as is, meaning that the fields
+ * will be in network byte order.
* @param payload Upon return will point to the location of the
* payload inside the packet.
* @param payloadlen Upon return will indicate the size of the payload.
@@ -285,7 +291,8 @@ PJ_DECL(pj_status_t) pjmedia_rtp_decode_rtp( pjmedia_rtp_session *ses,
* calculations.
*
* @param ses The session.
- * @param hdr The RTP header of the incoming packet.
+ * @param hdr The RTP header of the incoming packet. The header must
+ * be given with fields in network byte order.
* @param seq_st Optional structure to receive the status of the RTP packet
* processing.
*/
diff --git a/pjmedia/src/pjmedia/transport_ice.c b/pjmedia/src/pjmedia/transport_ice.c
index 71d19c24..56a45e8a 100644
--- a/pjmedia/src/pjmedia/transport_ice.c
+++ b/pjmedia/src/pjmedia/transport_ice.c
@@ -24,7 +24,7 @@
struct transport_ice
{
pjmedia_transport base;
- pj_ice_strans *ice_st;
+ pj_ice_strans *ice_st;
pj_time_val start_ice;
@@ -408,6 +408,9 @@ PJ_DEF(pj_status_t) pjmedia_ice_start_ice(pjmedia_transport *tp,
unsigned i, cand_cnt;
pj_ice_sess_cand cand[PJ_ICE_MAX_CAND];
const pjmedia_sdp_media *sdp_med;
+ pj_bool_t remote_is_lite = PJ_FALSE;
+ const pj_str_t STR_CANDIDATE = {"candidate", 9};
+ const pj_str_t STR_ICE_LITE = {"ice-lite", 8};
pj_str_t uname, pass;
pj_status_t status;
@@ -444,13 +447,17 @@ PJ_DEF(pj_status_t) pjmedia_ice_start_ice(pjmedia_transport *tp,
}
pass = attr->value;
- /* Get all candidates */
+ /* Get all candidates in the media */
cand_cnt = 0;
for (i=0; i<sdp_med->attr_count; ++i) {
pjmedia_sdp_attr *attr;
attr = sdp_med->attr[i];
- if (pj_strcmp2(&attr->name, "candidate")!=0)
+
+ if (pj_strcmp(&attr->name, &STR_ICE_LITE)==0)
+ remote_is_lite = PJ_TRUE;
+
+ if (pj_strcmp(&attr->name, &STR_CANDIDATE)!=0)
continue;
status = parse_cand(pool, &attr->value, &cand[cand_cnt]);
@@ -463,6 +470,16 @@ PJ_DEF(pj_status_t) pjmedia_ice_start_ice(pjmedia_transport *tp,
/* Mark start time */
pj_gettimeofday(&tp_ice->start_ice);
+ /* If our role was controlled but it turns out that remote is
+ * a lite implementation, change our role to controlling.
+ */
+ if (remote_is_lite &&
+ tp_ice->ice_st->ice->role == PJ_ICE_SESS_ROLE_CONTROLLED)
+ {
+ pj_ice_sess_change_role(tp_ice->ice_st->ice,
+ PJ_ICE_SESS_ROLE_CONTROLLING);
+ }
+
/* Start ICE */
return pj_ice_strans_start_ice(tp_ice->ice_st, &uname, &pass, cand_cnt, cand);
}
@@ -552,8 +569,8 @@ static pj_status_t tp_send_rtp(pjmedia_transport *tp,
{
struct transport_ice *tp_ice = (struct transport_ice*)tp;
return pj_ice_strans_sendto(tp_ice->ice_st, 1,
- pkt, size, &tp_ice->remote_rtp,
- sizeof(pj_sockaddr_in));
+ pkt, size, &tp_ice->remote_rtp,
+ sizeof(pj_sockaddr_in));
}
@@ -564,8 +581,8 @@ static pj_status_t tp_send_rtcp(pjmedia_transport *tp,
struct transport_ice *tp_ice = (struct transport_ice*)tp;
if (tp_ice->ice_st->comp_cnt > 1) {
return pj_ice_strans_sendto(tp_ice->ice_st, 2,
- pkt, size, &tp_ice->remote_rtp,
- sizeof(pj_sockaddr_in));
+ pkt, size, &tp_ice->remote_rtp,
+ sizeof(pj_sockaddr_in));
} else {
return PJ_SUCCESS;
}