mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Merge "res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP."
This commit is contained in:
@@ -13097,7 +13097,7 @@ static void add_codec_to_sdp(const struct sip_pvt *p,
|
|||||||
/* Opus mandates 2 channels in rtpmap */
|
/* Opus mandates 2 channels in rtpmap */
|
||||||
if (ast_format_cmp(format, ast_format_opus) == AST_FORMAT_CMP_EQUAL) {
|
if (ast_format_cmp(format, ast_format_opus) == AST_FORMAT_CMP_EQUAL) {
|
||||||
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u/2\r\n", rtp_code, mime, rate);
|
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u/2\r\n", rtp_code, mime, rate);
|
||||||
} else if ((35 <= rtp_code) || !(sip_cfg.compactheaders)) {
|
} else if ((AST_RTP_PT_LAST_STATIC < rtp_code) || !(sip_cfg.compactheaders)) {
|
||||||
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);
|
ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%u\r\n", rtp_code, mime, rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,6 +81,12 @@ extern "C" {
|
|||||||
/*! Maximum number of payload types RTP can support. */
|
/*! Maximum number of payload types RTP can support. */
|
||||||
#define AST_RTP_MAX_PT 128
|
#define AST_RTP_MAX_PT 128
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Last RTP payload type statically assigned, see
|
||||||
|
* http://www.iana.org/assignments/rtp-parameters
|
||||||
|
*/
|
||||||
|
#define AST_RTP_PT_LAST_STATIC 34
|
||||||
|
|
||||||
/*! First dynamic RTP payload type */
|
/*! First dynamic RTP payload type */
|
||||||
#define AST_RTP_PT_FIRST_DYNAMIC 96
|
#define AST_RTP_PT_FIRST_DYNAMIC 96
|
||||||
|
|
||||||
|
@@ -1426,28 +1426,31 @@ static int find_unused_payload(const struct ast_rtp_codecs *codecs)
|
|||||||
* https://tools.ietf.org/html/draft-roach-mmusic-unified-plan#section-3.2.1.2
|
* https://tools.ietf.org/html/draft-roach-mmusic-unified-plan#section-3.2.1.2
|
||||||
* https://tools.ietf.org/html/draft-wu-avtcore-dynamic-pt-usage#section-3
|
* https://tools.ietf.org/html/draft-wu-avtcore-dynamic-pt-usage#section-3
|
||||||
*/
|
*/
|
||||||
res = find_unused_payload_in_range(codecs, MAX(ast_option_rtpptdynamic, 35),
|
res = find_unused_payload_in_range(
|
||||||
|
codecs, MAX(ast_option_rtpptdynamic, AST_RTP_PT_LAST_STATIC + 1),
|
||||||
AST_RTP_PT_LAST_REASSIGN, static_RTP_PT);
|
AST_RTP_PT_LAST_REASSIGN, static_RTP_PT);
|
||||||
if (res != -1) {
|
if (res != -1) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Yet, reusing mappings below 35 is not supported in Asterisk because
|
/* Yet, reusing mappings below AST_RTP_PT_LAST_STATIC (35) is not supported
|
||||||
* when Compact Headers are activated, no rtpmap is send for those below
|
* in Asterisk because when Compact Headers are activated, no rtpmap is
|
||||||
* 35. If you want to use 35 and below
|
* send for those below 35. If you want to use 35 and below
|
||||||
* A) do not use Compact Headers,
|
* A) do not use Compact Headers,
|
||||||
* B) remove that code in chan_sip/res_pjsip, or
|
* B) remove that code in chan_sip/res_pjsip, or
|
||||||
* C) add a flag that this RTP Payload Type got reassigned dynamically
|
* C) add a flag that this RTP Payload Type got reassigned dynamically
|
||||||
* and requires a rtpmap even with Compact Headers enabled.
|
* and requires a rtpmap even with Compact Headers enabled.
|
||||||
*/
|
*/
|
||||||
res = find_unused_payload_in_range(
|
res = find_unused_payload_in_range(
|
||||||
codecs, MAX(ast_option_rtpptdynamic, 20), 35, static_RTP_PT);
|
codecs, MAX(ast_option_rtpptdynamic, 20),
|
||||||
|
AST_RTP_PT_LAST_STATIC + 1, static_RTP_PT);
|
||||||
if (res != -1) {
|
if (res != -1) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return find_unused_payload_in_range(
|
return find_unused_payload_in_range(
|
||||||
codecs, MAX(ast_option_rtpptdynamic, 0), 20, static_RTP_PT);
|
codecs, MAX(ast_option_rtpptdynamic, 0),
|
||||||
|
20, static_RTP_PT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -453,6 +453,7 @@ static int set_caps(struct ast_sip_session *session,
|
|||||||
static pjmedia_sdp_attr* generate_rtpmap_attr(struct ast_sip_session *session, pjmedia_sdp_media *media, pj_pool_t *pool,
|
static pjmedia_sdp_attr* generate_rtpmap_attr(struct ast_sip_session *session, pjmedia_sdp_media *media, pj_pool_t *pool,
|
||||||
int rtp_code, int asterisk_format, struct ast_format *format, int code)
|
int rtp_code, int asterisk_format, struct ast_format *format, int code)
|
||||||
{
|
{
|
||||||
|
extern pj_bool_t pjsip_use_compact_form;
|
||||||
pjmedia_sdp_rtpmap rtpmap;
|
pjmedia_sdp_rtpmap rtpmap;
|
||||||
pjmedia_sdp_attr *attr = NULL;
|
pjmedia_sdp_attr *attr = NULL;
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
@@ -461,6 +462,11 @@ static pjmedia_sdp_attr* generate_rtpmap_attr(struct ast_sip_session *session, p
|
|||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", rtp_code);
|
snprintf(tmp, sizeof(tmp), "%d", rtp_code);
|
||||||
pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp);
|
pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp);
|
||||||
|
|
||||||
|
if (rtp_code <= AST_RTP_PT_LAST_STATIC && pjsip_use_compact_form) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
|
rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
|
||||||
rtpmap.clock_rate = ast_rtp_lookup_sample_rate2(asterisk_format, format, code);
|
rtpmap.clock_rate = ast_rtp_lookup_sample_rate2(asterisk_format, format, code);
|
||||||
pj_strdup2(pool, &rtpmap.enc_name, ast_rtp_lookup_mime_subtype2(asterisk_format, format, code, options));
|
pj_strdup2(pool, &rtpmap.enc_name, ast_rtp_lookup_mime_subtype2(asterisk_format, format, code, options));
|
||||||
@@ -1260,11 +1266,9 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(attr = generate_rtpmap_attr(session, media, pool, rtp_code, 1, format, 0))) {
|
if ((attr = generate_rtpmap_attr(session, media, pool, rtp_code, 1, format, 0))) {
|
||||||
ao2_ref(format, -1);
|
media->attr[media->attr_count++] = attr;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
media->attr[media->attr_count++] = attr;
|
|
||||||
|
|
||||||
if ((attr = generate_fmtp_attr(pool, format, rtp_code))) {
|
if ((attr = generate_fmtp_attr(pool, format, rtp_code))) {
|
||||||
media->attr[media->attr_count++] = attr;
|
media->attr[media->attr_count++] = attr;
|
||||||
@@ -1293,12 +1297,10 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(attr = generate_rtpmap_attr(session, media, pool, rtp_code, 0, NULL, index))) {
|
if ((attr = generate_rtpmap_attr(session, media, pool, rtp_code, 0, NULL, index))) {
|
||||||
continue;
|
media->attr[media->attr_count++] = attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
media->attr[media->attr_count++] = attr;
|
|
||||||
|
|
||||||
if (index == AST_RTP_DTMF) {
|
if (index == AST_RTP_DTMF) {
|
||||||
snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code);
|
snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code);
|
||||||
attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp));
|
attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp));
|
||||||
|
Reference in New Issue
Block a user