From e883f579298af3ad169649a9cdc95d492d2206ee Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 15 Jul 2014 17:31:18 -0400 Subject: [PATCH] better support protocol switching within a call "initialized" now means that we've talked to the peer and that we know what they're advertising/supporting --- daemon/call.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index bc35125b6..8b99f9c69 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1675,10 +1675,8 @@ static void __ice_offer(const struct sdp_ng_flags *flags, struct call_media *thi return; /* we offer ICE by default */ - if (flags->opmode == OP_OFFER) { - if (!MEDIA_ISSET(this, INITIALIZED)) - MEDIA_SET(this, ICE); - } + if (!MEDIA_ISSET(this, INITIALIZED)) + MEDIA_SET(this, ICE); if (flags->ice_remove) MEDIA_CLEAR(this, ICE); @@ -1710,12 +1708,20 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi return; } - if (flags->opmode == OP_OFFER) { - /* we use this to remember the peer's preference DTLS vs SDES */ - if (!MEDIA_ISSET(this, INITIALIZED)) { - MEDIA_SET(this, DTLS); - MEDIA_SET(this, SDES); + if (!MEDIA_ISSET(this, INITIALIZED)) { + /* we offer both DTLS and SDES by default */ + MEDIA_SET(this, DTLS); + MEDIA_SET(this, SDES); + } + else { + /* if we're talking to someone understanding DTLS, then skip the SDES stuff */ + if (MEDIA_ISSET(this, DTLS)) { + MEDIA_CLEAR(this, SDES); + goto skip_sdes; } + } + + if (flags->opmode == OP_OFFER) { /* we always offer actpass */ MEDIA_SET(this, SETUP_PASSIVE); MEDIA_SET(this, SETUP_ACTIVE); @@ -1724,12 +1730,6 @@ static void __generate_crypto(const struct sdp_ng_flags *flags, struct call_medi /* if we can be active, we will, otherwise we'll be passive */ if (MEDIA_ISSET(this, SETUP_ACTIVE)) MEDIA_CLEAR(this, SETUP_PASSIVE); - - /* if we're answering and doing DTLS, then skip the SDES stuff */ - if (MEDIA_ISSET(this, DTLS)) { - MEDIA_CLEAR(this, SDES); - goto skip_sdes; - } } /* for answer case, otherwise we default to one */ @@ -1971,8 +1971,8 @@ int monologue_offer_answer(struct call_monologue *monologue, GQueue *streams, media->desired_family = AF_INET6; - /* mark initial offer/answer as done */ - MEDIA_SET(media, INITIALIZED); + /* we now know what's being advertised by the other side */ + MEDIA_SET(other_media, INITIALIZED); /* determine number of consecutive ports needed locally.