Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtp_engine: add support for multirate 2833 DRAFT #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbradeen
Copy link
Owner

DRAFT PR - demonstrate a method for handling non 8K 2833 digit sdp offers.

Changes to the engine itself limited to adding the 48/24K types.

res_pjsip_sdp_rtp is changed to note the number of incoming codecs and add an associated offer

@mbradeen mbradeen marked this pull request as draft November 28, 2023 17:00
@mbradeen
Copy link
Owner Author

cherry-pick-to: none

Copy link

@jcolp jcolp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the actual RTP traffic will flow as expected here. How does it know which negotiated AST_RTP_DTMF to use at a given time? As well, I believe res_rtp_asterisk is hardcoded to assume 8000Hz for DTMF for sending, specifically for timestamps. I think it needs to use the negotiated sample rate instead.

main/rtp_engine.c Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from b74fbb4 to df8b425 Compare December 11, 2023 19:37
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from df8b425 to 8bbd10c Compare January 8, 2024 18:57
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
main/rtp_engine.c Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch 2 times, most recently from a942c8e to 29ac748 Compare January 10, 2024 21:48
include/asterisk/format.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
main/format.c Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
if (rtp->lasttxformat == ast_format_none) {
/* No audio frames have been written yet so we have to lookup both the preferred payload type and bitrate. */
payload_format = ast_rtp_codecs_get_preferred(ast_rtp_instance_get_codecs(instance));
if(payload_format) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review needs a full review of spacing, if (payload_format) {

res/res_rtp_asterisk.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from 29ac748 to 146e916 Compare January 12, 2024 00:37
main/rtp_engine.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch 6 times, most recently from ce7eec7 to 563a625 Compare January 18, 2024 01:08
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from 563a625 to 494e3f2 Compare January 24, 2024 20:01
Copy link

@jcolp jcolp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments.

include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
main/rtp_engine.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch 2 times, most recently from 70a38c2 to 5166a55 Compare January 29, 2024 18:44
include/asterisk/rtp_engine.h Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
res/res_pjsip_sdp_rtp.c Outdated Show resolved Hide resolved
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from 5166a55 to ff866a0 Compare January 30, 2024 17:48
if (AST_VECTOR_INIT(&sampleRates, 1)) {
ast_log(LOG_ERROR, "Unable to allocate dtmf payload types.\n");
buildSampleRates = 0;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; ?

@@ -1900,6 +1946,12 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
ast_format_cap_append_from_cap(caps, ast_stream_get_formats(stream), media_type);
}

/* Init the sample rates before we start adding them. Assume we will have at least one. */
if (AST_VECTOR_INIT(&sampleRates, 1)) {
ast_log(LOG_ERROR, "Unable to allocate dtmf payload types.\n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a user perspective this isn't really informational

2833 payload offers. */
AST_VECTOR(, int) sampleRates;
/* In case we can't init the sample rates, still try to do the rest. */
int buildSampleRates = 1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_dtmf_sample_rates to be more accurate and follow existing variable naming

if ((attr = generate_rtpmap_attr(session, media, pool, rtp_code, 0, NULL, index))) {
media->attr[media->attr_count++] = attr;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else if {

*
* This looks for the numerical payload for a DTMF type with a sample rate of 8kHz in the codecs structure.
*
* \since 21.0.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version on all of these will need to be updated whenever this goes in.

if (!new_type) {
return -1;
}

ast_rwlock_wrlock(&codecs->codecs_lock);

/* Go through the existing mapping to create an ignore list. */
for (i = 0; i < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); i++) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me thinking, but could this ever be higher than AST_RTP_MAX_PT or does codecs->payload_mapping_rx also abide by that sizing limit?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are safe, elements only get replaced. This is how other functions walk this vector.

/*
* The payload type is a static assignment
* or our default dynamic position is available.
*/
rtp_codecs_payload_replace_rx(codecs, payload, new_type);
} else if ( payload > -1 && !explicit
/* We can either call this with the the full list or the current rx list. The former
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double "the"

set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 8000);
set_next_mime_type(NULL, AST_RTP_DTMF, "audio", "telephone-event", 48000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason 48k needs to be right here, or does order not matter?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the two I think are most common, but I could be biased based on how I was testing.

int rtp_code, int asterisk_format, struct ast_format *format, int code, int sample_rate)
{
#ifndef HAVE_PJSIP_ENDPOINT_COMPACT_FORM
extern pj_bool_t pjsip_use_compact_form;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be initialized to anything?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, this function is a copy of generate_rtpmap_attr but with the sample_rate variable.


/* Keep track of the sample rates for offered codecs so we can build matching
2833 payload offers. */
AST_VECTOR(, int) sampleRates;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample_rates

@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from ff866a0 to adfa991 Compare February 22, 2024 20:12
DRAFT PR - demonstrate a method for handling non 8K
2833 digit sdp offers.

Changes to the engine itself limited to adding the 48/24K types.

res_pjsip_sdp_rtp is changed to note the number of incoming codecs
and add an associated offer
@mbradeen mbradeen force-pushed the rtp-engine-2833-multirate branch from adfa991 to 1c35432 Compare February 22, 2024 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants