summaryrefslogtreecommitdiff
path: root/res/res_pjsip_sdp_rtp.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_pjsip_sdp_rtp.c')
-rw-r--r--res/res_pjsip_sdp_rtp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 97e365c10..c5a673aa4 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -410,13 +410,29 @@ static int set_caps(struct ast_sip_session *session,
ast_format_cap_append_from_cap(caps, ast_channel_nativeformats(session->channel),
AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_remove_by_type(caps, media_type);
+
if (session->endpoint->preferred_codec_only){
struct ast_format *preferred_fmt = ast_format_cap_get_format(joint, 0);
ast_format_cap_append(caps, preferred_fmt, 0);
ao2_ref(preferred_fmt, -1);
+ } else if (!session->endpoint->asymmetric_rtp_codec) {
+ struct ast_format *best;
+ /*
+ * If we don't allow the sending codec to be changed on our side
+ * then get the best codec from the joint capabilities of the media
+ * type and use only that. This ensures the core won't start sending
+ * out a format that we aren't currently sending.
+ */
+
+ best = ast_format_cap_get_best_by_type(joint, media_type);
+ if (best) {
+ ast_format_cap_append(caps, best, ast_format_cap_get_framing(joint));
+ ao2_ref(best, -1);
+ }
} else {
ast_format_cap_append_from_cap(caps, joint, media_type);
}
+
/*
* Apply the new formats to the channel, potentially changing
* raw read/write formats and translation path while doing so.