<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 30, 2017 at 4:44 PM, George Joseph <span dir="ltr"><<a href="mailto:gjoseph@digium.com" target="_blank">gjoseph@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Jan 30, 2017 at 3:32 PM, Matthew Jordan <span dir="ltr"><<a href="mailto:mjordan@digium.com" target="_blank">mjordan@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-1247727568534216736h5">On Mon, Jan 30, 2017 at 3:22 PM, Matt Fredrickson <span dir="ltr"><<a href="mailto:creslin@digium.com" target="_blank">creslin@digium.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Michael,<br>
<br>
First off, thanks for taking the time to express some of your thoughts<br>
and concerns to the asterisk-dev list. I'll keep my reply to your<br>
email inline below.<br>
<span><br>
On Mon, Jan 30, 2017 at 4:13 AM, Michael Maier <<a href="mailto:m1278468@allmail.net" target="_blank">m1278468@allmail.net</a>> wrote:<br>
> Dear developers,<br>
><br>
> I've been redirected to this mailing list by Joshua Colp during fixing a<br>
> one way audio bug[1] to discuss another solution as provided in the fix.<br>
><br>
> Background:<br>
> - A lot of people complain about bad VoIP call quality compared to the<br>
> old POTS / ISDN devices. What do they mean from a technical point of<br>
> view: High latencies (resulting in echo), digital sound because of "bad"<br>
> codecs, general quality loss during transcoding and many other reasons more.<br>
> - In Europe, HD audio is being adopted slowly. This means, more and more<br>
> UAs can natively handle HD codecs like g722. But they must be downward<br>
> compatible at the same time for older UAs, which just speak alaw (like<br>
> the old POTS devices e.g. or UAs which are not yet HD capable).<br>
> Therefore, they advertise at least two codecs: g722 and alaw (mostly<br>
> plus some more like ulaw or some other codecs).<br>
<br>
</span>So there are multiple reasons why you could be seeing reportedly bad<br>
call quality that come to my mind:<br>
<br>
1. Transcoding - changes the audio, but typically doesn't make things<br>
sound *too* bad. Obviously it is codec dependent as to how bad it<br>
sounds afterwards, but most modern codecs aren't terrible for speech<br>
replication and encoding. Usually this is not where call quality<br>
problems are noticed.<br>
<br>
2. Packet loss and jitter related problems. In an ISDN network, there<br>
is a guaranteed real time audio channel for transporting media. As<br>
long as the data pumps on the transmit and receive side are working<br>
properly, you should hear almost no audio quality issues. VoIP tries<br>
to transport real time audio over a non-guaranteed transport channel.<br>
This sometimes causes bad audio quality issues due to packet loss,<br>
packet reordering, or extreme packet delays. Enabling Asterisk's<br>
jitter buffers typically improves many problems that arise due to<br>
this. They are typically *not* enabled by default and so must be<br>
explicitly enabled.<br>
<br>
I'm hoping you already have dived into your problem to look at both<br>
the above elements, and have confirmed that you are not dealing with<br>
the second problem instead of voice mutation due to the first problem.<br>
Usually you can track the second problem by doing packet captures of<br>
the voice conversations in question as well as look at RTCP<br>
statistics.<br>
<span><br>
> What does this mean to Asterisk?<br>
> My conviction is, that Asterisk shouldn't make things even worse when<br>
> handling calls / codecs by forcing unnecessary transcoding, which<br>
> unnecessarily harms call quality. Next point of unnecessary transcoding:<br>
> it unnecessarily steals system resources from the machine asterisk is<br>
> running on.<br>
> Asterisk should harm each call it handles and the underlying machine as<br>
> little as possible.<br>
><br>
> Therefore I would like to see a (switchable) feature, that asterisk /<br>
> pjsip always tries to primarily advertise codecs, which are supported by<br>
> both UAs and remove those codecs, which are not supported by one of the<br>
> UAs. This prevents unnecessary transcoding.<br>
<br>
</span>This actually would be a really neat thing for Asterisk to be able to<br>
do. Last time I looked at it, there are quite a few challenges in<br>
making it happen. Asterisk is designed to be a back to back user<br>
agent, and it inherently is designed to terminate media and codecs<br>
individually with each leg in question, but not necessarily together.<br>
It "makes things work" on each leg separately, based on the allowed<br>
codecs for each endpoint.<br>
<br>
This is a needful behavior since many times an Answer() has already<br>
occurred and negotiated the codec capabilities for a call and most<br>
dial plan applications assume a call needs to have media fully<br>
negotiated in order to interact on the channel.<br>
<br>
For the simple case where your dial plan doesn't do any intense media<br>
interaction with a channel and simply Dial()'s out, a significant<br>
portion that doesn't work right now is that the codec information from<br>
the 200 OK received from the outbound channel is not passed back<br>
through to the inbound channel - I'm assuming that's what you're<br>
referring to. Hopefully Josh or Mark will correct me if my memory is<br>
off.<br>
<div><div class="m_-1247727568534216736m_2955224055557338020h5"><br></div></div></blockquote><div><br></div></div></div><div>We've looked at doing this several times.</div><div><br></div><div>The last time I gave that a shot I more or less had it working, and then broke myself (and my patch) on the rocks of Local channels. Trying to get Local channel chains to respect the codecs down a chain (generally 3+ is enough to trip errors) is a non-trivial operation. When setting up the call you more or less can control the situation - the codec preferences are passed down the chain via ast_request. However, when things are coming back in the other direction, you don't have an easy reference to the channel that created you. It can involve reaching across bridges and local channel bridges, which is dangerous. Both are prone to error and deadlocks. Holding a reference to your creator isn't safe, as the creator can be masqueraded away (in really weird situations). The other option is to pass the information down in a frame, but now you can't guarantee much, as that's an asynchronous operation.</div><div><br></div><div>In transcoding situations, you also have to pick where in that chain you choose to do transcoding - which is not always easy to figure out.</div><div><br></div><div>Things get challenging as well when you have a multi-party bridge involved at all - either when a dialed party has to be placed into a multi-party bridge or when you have a chain of Local channels dialing someone and the far end of the Local channel chain is already in a multi-party bridge.</div><div><br></div><div>Generally, this is an architectural limitation of Asterisk that - while not impossible to craft a solution for - is far harder than it may seem when you're only thinking of two-party calling with non-Local channels.</div></div></div></div></blockquote><div><br></div></div></div><div>How hard do you think it would it be to limit the attempt to the 90% use case of a call coming in on one channel and causing an originate going out on another channel? Simple PBX scenarios? No answer in the middle, no early media, etc.</div><div><br></div></div></div></div></blockquote><div><br></div><div>A lot of the code in the core or in specific channel drivers - which is where this would need to be located - tries hard to not make assumption about the number of participants in a bridge or the types of channels it is working with.</div></div><div class="gmail_extra"><br></div>I think you'd end up with a lot of junk lying around doing things like:</div><div class="gmail_extra"><br></div><div class="gmail_extra">if (number of participants in bridge is 2) {</div><div class="gmail_extra"> // do cool things</div><div class="gmail_extra">} else {</div><div class="gmail_extra"> // behave normally</div><div class="gmail_extra">}<br clear="all"><div><br></div><div>Or worse:</div><div><br></div><div>if (I am not bridged with a Local channel and I'm not in a bridge with more than one other channel) {</div><div> // do cool things</div><div>}</div><div><br></div><div>Which just gets ugly and hard(er) to maintain.</div><div><br></div><div>I could be wrong about the scope of this, but that's more or less what I found when I played around with a similar notion.</div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Matthew Jordan<br>Digium, Inc. | CTO<br>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a></div>
</div></div>