diff --git a/daemon/call.c b/daemon/call.c index 94aedec98..f40a0e77a 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1873,6 +1873,12 @@ static void __update_media_protocol(struct call_media *media, struct call_media if (!flags) return; + /* allow override of outgoing protocol even if we know it already */ + /* but only if this is an RTP-based protocol */ + if (flags->transport_protocol + && proto_is_rtp(other_media->protocol)) + media->protocol = flags->transport_protocol; + // OSRTP offer requested? if (media->protocol && media->protocol->rtp && !media->protocol->srtp && media->protocol->osrtp_proto && flags->osrtp_offer && flags->opmode == OP_OFFER) @@ -1915,14 +1921,6 @@ static void __update_media_protocol(struct call_media *media, struct call_media __t38_reset(media, other_media); // drop through for protocol override } - - /* allow override of outgoing protocol even if we know it already */ - /* but only if this is an RTP-based protocol */ - if (flags->transport_protocol - && proto_is_rtp(other_media->protocol)) { - media->protocol = flags->transport_protocol; - return; - } } /* called with call->master_lock held in W */ diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 42a8bf997..7ed5fcf1c 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -630,6 +630,77 @@ rcv($sock_a, $port_b, rtpm(0, 2000, 4000, 0x3456, "\x00" x 160)); +($sock_a, $sock_b) = new_call([qw(198.51.100.1 3356)], [qw(198.51.100.3 3358)]); + +($port_a, undef, $srtp_key_a) = offer('non-OSRTP offer with offer flag and protocol, accept', + { ICE => 'remove', replace => ['origin'], DTLS => 'off', OSRTP => ['offer'], + 'transport protocol' => 'RTP/AVP'}, < 'remove', replace => ['origin'], DTLS => 'off', }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'Kl3GFJ5Gqz5x07xYkoyHODkVkSpiplZnXsQIw+Q7', +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => $srtp_key_a, +}; + +snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234, "\x00" x 160)); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_b, $port_a, rtp(0, 2000, 4000, 0x3456, "\x00" x 160), $srtp_ctx_a); +rcv($sock_a, $port_b, rtpm(0, 2000, 4000, 0x3456, "\x00" x 160)); + +