-
Notifications
You must be signed in to change notification settings - Fork 932
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
core,app_dial,pjsip: Implement Advanced Codec Negotiation (ACN) #285
base: master
Are you sure you want to change the base?
core,app_dial,pjsip: Implement Advanced Codec Negotiation (ACN) #285
Conversation
cherry-pick-to: 21 |
I haven't looked at the code, just the upgrade note, but the options can not be removed. They must continue to exist. |
This PR must be tested with the corresponding testsuite PR which adds 48 tests to test the codec negotiation: Further, 10 tests were adopted to reflect the new behavior. For those tests, |
@jcolp And they must continue to work? Or silently be ignored like the ACN settings were? I'm not sure if I see a way for both settings to co-exist without interfering with each other. |
Yes. We can not remove options in minor versions, or alter their behavior, unless there is a critical reason why - such as a security issue. This does not rise to that level. |
For example, if the options are kept but default to empty in the code we can determine that they are actually unset. Default behavior should remain the same in that case even if the options were removed. If they are set then those settings take priority. If unset then the other options take priority.
|
Makes sense, I probably should have checked with the maintainers first. So would it be an option for Asterisk 21? |
Asterisk 21, once branched, can no longer receive breaking changes. |
I'm sticking to the policy that breaking changes are for standard releases, which next would be 23. If this change can be altered to maintain backwards compatibility then it would be eligible for all. |
Ok, then I will look into your suggestion and try to find a way to not change the existing behavior and not remove any settings. Is it possible to mark this PR as a draft while I do that? |
I've converted it to a draft. |
Consider the case where neither the "old" options
They must be set to |
Thanks for picking this up!!! |
@gtjoseph Thank you! I am now incorporating Joshua's remarks and I noticed that some fax/pjsip tests failed (which I didn't check). So this is still a WIP, but we have confirmed that the ACN is working as expected (e.g. see the linked testsuite PR and we have done manual testing as well). |
To be more precise, I think the logic should be: As soon as one of I think everything else would lead to maximum confusion. I will state this in the docs for the settings. |
Update: We can not really invest more time into making this patch also work with the old settings. @jcolp Is the removal of the We are confident that this patch implements ACN as it is supposed to, the only missing piece seems to be the failing fax tests. |
There is a waiting-for-standard-release-development-cycle label for this purpose, that could be applied. But I'm not sure contributors can add it themselves. |
I've added it. |
c6b7d4b
to
31abe63
Compare
This leaks some memory. Following patch fixes it. Unsure, if this is the correct approach though. @maximilianfridrich
|
709a3dc
to
b85addb
Compare
Thank you for looking at it @btriller. That seems right. I declared both variables with the Also, please be aware that this patch as it is now breaks some of the fax/pjsip tests. The failing pjsip tests on GitHub are due to it not running it with the corresponding testsuite PR. |
There's another issue, that leads to no audio, if a client sends more streams than endpoint's capability. See #344 @maximilianfridrich |
I'm not sure if I can follow. Could you please describe the scenario in more detail (endpoint config, and who answers/offers what)? Update: Maybe all you need is |
res/res_pjsip_session.c
Outdated
@@ -5401,6 +5611,8 @@ static void session_inv_on_create_offer(pjsip_inv_session *inv, pjmedia_sdp_sess | |||
SCOPE_EXIT_RTN("%s: create offer failed\n", ast_sip_session_get_name(session)); | |||
} | |||
|
|||
ast_sip_session_media_state_reset(session->pending_media_state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to cause no audio with all_codecs_on_empty_reinvite=yes
when a UA renegotiates a different codec. See [1] for reproducing this issue. Seems to be fixed with
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 5486a97040..72b4130a40 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -5594,25 +5594,23 @@ static void session_inv_on_create_offer(pjsip_inv_session *inv, pjmedia_sdp_sess
}
}
- if (inv->neg) {
- if (pjmedia_sdp_neg_was_answer_remote(inv->neg)) {
- pjmedia_sdp_neg_get_active_remote(inv->neg, &previous_sdp);
- } else {
- pjmedia_sdp_neg_get_active_local(inv->neg, &previous_sdp);
- }
- }
-
if (ignore_active_stream_topology) {
offer = create_local_sdp(inv, session, NULL, 1);
} else {
+ if (inv->neg) {
+ if (pjmedia_sdp_neg_was_answer_remote(inv->neg)) {
+ pjmedia_sdp_neg_get_active_remote(inv->neg, &previous_sdp);
+ } else {
+ pjmedia_sdp_neg_get_active_local(inv->neg, &previous_sdp);
+ }
+ }
offer = create_local_sdp(inv, session, previous_sdp, 0);
+ ast_sip_session_media_state_reset(session->pending_media_state);
}
if (!offer) {
SCOPE_EXIT_RTN("%s: create offer failed\n", ast_sip_session_get_name(session));
}
- ast_sip_session_media_state_reset(session->pending_media_state);
-
ast_queue_unhold(session->channel);
/*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't doubt it, but the provided testcase passes for me even without your suggested patch. Is it testing exactly the scenario you described?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negotiating codecs works fine without the patch but there's no audio (no RTP sent) after negotiating a new codec. I don't know how to verify that RTP is sent (maybe it's possible to check for RTP AMI events?). IIRC without the patch there's following log message
res_pjsip_sdp_rtp.c:487 set_caps: No joint capabilities for 'audio' media stream between our configuration((alaw)) and incoming SDP((g722))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, maybe I can find a way to test it. Thank you for clarifying.
There's another memory leak. Please check following patch. @maximilianfridrich
|
Former patch leads to crashes. Following seams more appropriate
|
That looks good, thank you for the find! |
b85addb
to
317a31e
Compare
Advanced Codec Negotiation is now implemented for the dial application, pjsip channels and local channels. Resolves: asterisk#223 UpgradeNote: The two pjsip.conf options "incoming_call_offer_pref" and "outgoing_call_offer_pref" have been removed. Instead, the new options "codec_prefs_incoming_answer", "codec_prefs_incoming_offer", "codec_prefs_outgoing_answer", "codec_prefs_outgoing_offer" must be used. Even if the old settings were not used, this could break existing deployments as the default ACN options are now in use and they might behave differently in some call flows (e.g. by default, pending codecs are always preferred, not the endpoint configuration). UserNote: The Advanced Codec Negotiation feature is now implemented.
317a31e
to
eb5b500
Compare
Hey Maximilianfridrich, Have you got a version of this patch for version 20 available? |
@SirDMZ I tested the patches with Asterisk 20, they should work. A recent change (by me) has now created a conflict but it should be very easy to resolve. |
Advanced Codec Negotiation is now implemented for the dial application, pjsip channels and local channels.
Resolves: #223
UpgradeNote: The two pjsip.conf options "incoming_call_offer_pref" and "outgoing_call_offer_pref" have been removed. Instead, the new options "codec_prefs_incoming_answer", "codec_prefs_incoming_offer", "codec_prefs_outgoing_answer", "codec_prefs_outgoing_offer" must be used. Even if the old settings were not used, this could break existing deployments as the default ACN options are now in use and they might behave differently in some call flows (e.g. by default, pending codecs are always preferred, not the endpoint configuration).
UserNote: The Advanced Codec Negotiation feature is now implemented.