diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 7c7040e35b..f2cac015f0 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -768,9 +768,11 @@ static enum ast_sip_session_media_encryption check_endpoint_media_transport( char transport_end = stream->desc.transport.ptr[stream->desc.transport.slen - 1]; unsigned int optimistic; - if ((transport_end == 'F' && !endpoint->media.rtp.use_avpf) - || (transport_end != 'F' && endpoint->media.rtp.use_avpf)) { - return AST_SIP_MEDIA_TRANSPORT_INVALID; + if(!endpoint->media.rtp.use_received_transport) { + if ((transport_end == 'F' && !endpoint->media.rtp.use_avpf) + || (transport_end != 'F' && endpoint->media.rtp.use_avpf)) { + return AST_SIP_MEDIA_TRANSPORT_INVALID; + } } incoming_encryption = get_media_encryption_type(stream->desc.transport, stream, &optimistic); @@ -779,7 +781,7 @@ static enum ast_sip_session_media_encryption check_endpoint_media_transport( return incoming_encryption; } - if (endpoint->media.rtp.force_avp || + if ((!endpoint->media.rtp.use_received_transport && endpoint->media.rtp.force_avp) || endpoint->media.rtp.encryption_optimistic) { return incoming_encryption; } @@ -1014,14 +1016,14 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct } /* Ensure incoming transport is compatible with the endpoint's configuration */ - if (!session->endpoint->media.rtp.use_received_transport) { - encryption = check_endpoint_media_transport(session->endpoint, stream); + encryption = check_endpoint_media_transport(session->endpoint, stream); - if (encryption == AST_SIP_MEDIA_TRANSPORT_INVALID) { - return -1; - } + if (encryption == AST_SIP_MEDIA_TRANSPORT_INVALID) { + return -1; } + session_media->encryption = encryption; + ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr, sizeof(host)); /* Ensure that the address provided is valid */