mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
res_pjsip_sdp_rtp: Use negotiated DTMF Payload types on bitrate mismatch
When Asterisk sends an offer to Bob that includes 48K and 8K codecs with
matching 4733 offers, Bob may want to use the 48K audio codec but can not
accept 48K digits and so negotiates for a mixed set.
Asterisk will now check Bob's offer to make sure Bob has indicated this is
acceptible and if not, will use Bob's preference.
Fixes: #847
(cherry picked from commit ac673dd14e
)
This commit is contained in:
committed by
Asterisk Development Team
parent
57242cbe31
commit
8ad9f7d320
@@ -1217,6 +1217,16 @@ static int payload_mapping_tx_is_present(const struct ast_rtp_codecs *codecs, co
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_rtp_payload_mapping_tx_is_present(struct ast_rtp_codecs *codecs, const struct ast_rtp_payload_type *to_match) {
|
||||
int ret = 0;
|
||||
if (codecs && to_match) {
|
||||
ast_rwlock_rdlock(&codecs->codecs_lock);
|
||||
ret = payload_mapping_tx_is_present(codecs, to_match);
|
||||
ast_rwlock_unlock(&codecs->codecs_lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Copy the tx payload type mapping to the destination.
|
||||
@@ -1289,6 +1299,8 @@ void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_cod
|
||||
rtp_codecs_payloads_copy_tx(src, dest, instance);
|
||||
dest->framing = src->framing;
|
||||
ao2_replace(dest->preferred_format, src->preferred_format);
|
||||
dest->preferred_dtmf_rate = src->preferred_dtmf_rate;
|
||||
dest->preferred_dtmf_pt = src->preferred_dtmf_pt;
|
||||
|
||||
ast_rwlock_unlock(&src->codecs_lock);
|
||||
ast_rwlock_unlock(&dest->codecs_lock);
|
||||
@@ -1332,6 +1344,8 @@ void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_co
|
||||
|
||||
dest->framing = src->framing;
|
||||
ao2_replace(dest->preferred_format, src->preferred_format);
|
||||
dest->preferred_dtmf_rate = src->preferred_dtmf_rate;
|
||||
dest->preferred_dtmf_pt = src->preferred_dtmf_pt;
|
||||
|
||||
if (src != dest) {
|
||||
ast_rwlock_unlock(&src->codecs_lock);
|
||||
@@ -1572,6 +1586,33 @@ int ast_rtp_codecs_set_preferred_format(struct ast_rtp_codecs *codecs, struct as
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_rtp_codecs_get_preferred_dtmf_format_pt(struct ast_rtp_codecs *codecs)
|
||||
{
|
||||
int pt = -1;
|
||||
ast_rwlock_rdlock(&codecs->codecs_lock);
|
||||
pt = codecs->preferred_dtmf_pt;
|
||||
ast_rwlock_unlock(&codecs->codecs_lock);
|
||||
return pt;
|
||||
}
|
||||
|
||||
int ast_rtp_codecs_get_preferred_dtmf_format_rate(struct ast_rtp_codecs *codecs)
|
||||
{
|
||||
int rate = -1;
|
||||
ast_rwlock_rdlock(&codecs->codecs_lock);
|
||||
rate = codecs->preferred_dtmf_rate;
|
||||
ast_rwlock_unlock(&codecs->codecs_lock);
|
||||
return rate;
|
||||
}
|
||||
|
||||
int ast_rtp_codecs_set_preferred_dtmf_format(struct ast_rtp_codecs *codecs, int pt, int rate)
|
||||
{
|
||||
ast_rwlock_wrlock(&codecs->codecs_lock);
|
||||
codecs->preferred_dtmf_pt = pt;
|
||||
codecs->preferred_dtmf_rate = rate;
|
||||
ast_rwlock_unlock(&codecs->codecs_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
|
||||
{
|
||||
struct ast_rtp_payload_type *type;
|
||||
@@ -2087,6 +2128,16 @@ int ast_rtp_codecs_payload_code_tx_sample_rate(struct ast_rtp_codecs *codecs, in
|
||||
ast_rwlock_rdlock(&static_RTP_PT_lock);
|
||||
payload = find_static_payload_type(asterisk_format, format, code);
|
||||
ast_rwlock_unlock(&static_RTP_PT_lock);
|
||||
|
||||
ast_rwlock_rdlock(&codecs->codecs_lock);
|
||||
if (payload >= 0 && payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)){
|
||||
type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
|
||||
if (!type || (sample_rate != 0 && type->sample_rate != sample_rate)) {
|
||||
/* Don't use the type if we can't find it or it doesn't match the supplied sample_rate */
|
||||
payload = -1;
|
||||
}
|
||||
}
|
||||
ast_rwlock_unlock(&codecs->codecs_lock);
|
||||
}
|
||||
|
||||
return payload;
|
||||
|
Reference in New Issue
Block a user