[Home]

Summary:ASTERISK-29198: allow=audio,video,text: First codec must be an audio codec.
Reporter:Alexander Traud (traud)Labels:patch
Date Opened:2020-12-06 01:46:26.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Channels/chan_sip/CodecHandling Core/General
Versions:16.15.0 18.1.0 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) append_cap_except.patch
( 1) audio_not_first.patch
( 2) extensions.conf
( 3) sip.conf
Description:If the first codec in the list of allows is not an audio codec, not only the channel driver chan_sip but many more modules get crazy.

*Steps to Reproduce*
1. configuration file {{sip.conf}} with {{allow=h264,ulaw}} in the \[general\] section
2. from one extension, dial another extension

*Actual Results*
{code}WARNING: channel.c: set_format: Unable to find a codec translation path: (h264) -> (ulaw)
WARNING: channel.c: set_format: Unable to find a codec translation path: (ulaw) -> (h264){code}

*Next Steps*
A search with the Regular Expression {{ast_format_cap_get_format\(.+, 0\);}} revealed many channels and modules seem affected like {{app_mp3}}, {{core_unreal}}, and {{res_speech}}. However, I did not test those. Even {{chan_sip}} has one more place in source code, which looks affected: When the ptime / framing is negotiated.

The attached patch fixes just the reported scenario, the bug in {{main/channel.c}}. There, the code assumes audio codecs only anyway; therefore I added a filter. After fixing that, I had to fix another bug in {{channels/chan_sip.c}} to get the scenario above working. I did not analyze/understand all other occurrences. Therefore, it might be better to
a) place a note in the documentation rather than fixing this, or
b) sort the codecs while importing the configuration,
c) go through the _whole_ code and revise this.
In any case, I am not sure if it helps anyone if I patch just the reported issue. From my point of view, that would not solve but hide the problem just deeper. What do you think?

*Workaround*
The first allowed codec must be an audio codec. Therefore it is best when you go for {{allow=audio,video,text}}.
Comments:By: Asterisk Team (asteriskteam) 2020-12-06 01:46:28.871-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Kevin Harwell (kharwell) 2020-12-07 16:15:12.163-0600

Hrm, I'm having trouble reproducing this (even in _chan_sip_). Can you post your exact configuration please.

By: Asterisk Team (asteriskteam) 2020-12-22 12:00:02.911-0600

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines

By: Alexander Traud (traud) 2021-01-15 07:49:21.686-0600

Argh. Found the puzzle piece which was missing in my issue description: {{disallow=all}}. Then {{sip show settings}} on the command-line interface shows {{h264,ulaw}} for ‘Codecs’. Now, the order is video,audio. And the warning is printed when both phones support H.264.

Without that, {{allow=}} just appends H.264 to the existing codecs. The order stayed audio,video.

Attached are my sip.conf and extensions.conf for chan_sip. Tested with the yesterday released Asterisk 18.2.0-rc1.

By: Asterisk Team (asteriskteam) 2021-01-15 07:49:22.065-0600

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Benjamin Keith Ford (bford) 2021-01-15 09:49:45.042-0600

Were you going to submit this for review on Gerrit?

By: Alexander Traud (traud) 2021-01-15 11:00:06.101-0600

No. I need a decision how to proceed. Furthermore, this issue is minor but requires attention by the Asterisk Team because many modules might be affected. I provided an example patch for the reported issue on the mailing list. That patch fixes just the report of the mailing list.

By: Joshua C. Colp (jcolp) 2021-01-18 04:15:57.616-0600

I think the least invasive option would be best for this. That means either documentation or sorting the codecs when configured. I do not think it is worth it to make changes throughout the tree to resolve this, and there is a chance of breaking things as a result just to resolve this.

The negative of sorting the codecs is that they no longer reflect the actual configuration, which may confuse individuals, so I lean more towards documentation.

By: Alexander Traud (traud) 2021-01-18 10:24:11.836-0600

While investigating another issue, just today, I noticed that this ‘audio-first’ assumption is violated even internally. With the Regular Expression {{ast_format_cap_remove_by_type\(.+, AST_MEDIA_TYPE_AUDIO\);}}, I found four places which sort ‘audio-last’ themselves:{code}chan_pjsip_read_stream
chan_sip.c:sip_new
chan_sip.c:sip_rtp_read
channel.c:request_channel{code}For the last one, the general Channel code, I attached an example patch again. Therefore, I do not go forward with case A or B because this would not fix internal ‘audio-last’ situations. And nobody knows if those format capabilities meet code which expect ‘audio-first’. Consequently, I have to ask for a general code review, case C.

By: Joshua C. Colp (jcolp) 2021-01-20 05:41:52.841-0600

I'm confused by your statement:

Consequently, I have to ask for a general code review, case C.

Are you asking someone to review your patches as attached on this issue?

By: Alexander Traud (traud) 2021-01-20 10:43:26.389-0600

bq. I did not analyze/understand all other occurrences. Therefore, it might be better to … c) go through the whole code \[of Asterisk\] and revise this.

One of the core modules, {{main/channel.c}}, is mis-using the list of capabilities. On the one hand side, that module assumes audio to be first. On the other hand, it puts audio last. Today, I found another, a third, scenario besides mis-configuration and wrong internal use: external trigger. Place a video-only call (or a call with video but with all audio formats rejected). In that case, {{main/channel.c}} prints for the echo test
bq. Unable to find a codec translation path: (list of installed sound formats via {{menu select}}) -> (h264)
However, {{main/channel.c}} has to print
bq. Unable to set format because channel %s supports no formats
The latter would happen with my attached patches. Great! Although the wording has to be improved. However, however, that is printed not with the severity of {{NOTICE}} but as {{ERROR}}. In that case, I only tested Asterisk 13.38.1 with chan_sip.

Anyway,
* because this can be triggered externally,
* because an error is logged in a ‘normal’ situation,

that tells me, we are in badlands.

Somebody with a bird’s-eye view should have a look at the whole Asterisk code. Especially because so many modules might be affected. I just have a worm’s-eye view. This review could be done in the course of the upcoming Advanced Codec Negotiation (ACN; [mailing list|http://lists.digium.com/pipermail/asterisk-dev/2020-June/thread.html], [blog post|https://www.asterisk.org/asterisk-acn-advanced-codec-negotiation/], [wiki entry|https://wiki.asterisk.org/wiki/display/AST/PJSIP+Advanced+Codec+Negotiation]).

The two attached patches, you can use them. They fix a lot already. However, I fear they hide the issue just deeper. They do not fix the issue in general. Some code parts assume that the first format is audio. Some code parts put audio last. Some code parts go through the full capabilities, although they should go through the audio capabilities only. I hate to get worked up over this without providing a complete fix, and the issue looked easy at the first user report – however, from my point of view, this looks bigger. Therefore, case C.

By: N A (InterLinked) 2022-02-09 18:08:25.474-0600

This issue also seems to affect combined audio+video calls using Originate.

For instance, using C(slin,h264), that can sometimes result in this error:

WARNING: channel.c: set_format: Unable to find a codec translation path: (ulaw) -> (h264)