<div dir="ltr"><div>Thanks for your response Michael!</div><div><br></div><div>I'm going to top-post because this is a long thread and I just wanted to say that we pretty much agree with the behaviors you've outlined and, in fact, those will probably be the default behaviors. I also like the "principles" you noted and will expand on those in a future email.</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 6, 2020 at 12:21 AM Michael Maier <<a href="mailto:m1278468@mailbox.org">m1278468@mailbox.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On June 03, 2020 at 22:17 George Joseph wrote:<br>
> Greetings All,<br>
> <br>
> We've been working hard on new codec negotiation stuff for Asterisk 18 and<br>
> we've got some stuff to run by you. It's a lot so please read carefully.<br>
<br>
Thank you very much for your ongoing effort! I really appreciate it!<br>
I additionally read this documentation here [1].<br>
During writing down those lines I got the feeling how complicated could be ... .<br>
<br>
<br>
Therefore there must be some basic principals on how to handle things. I tried to write them down as follows:<br>
<br>
0. Asterisk is the only one which decides the codecs to be used on base of the allow list on each leg phone <-> Asterisk because I want to be sure about the codecs used on each leg<br>
(because of existing network bandwidth restrictions e.g.)<br>
1. The phone must support at least one of the codecs of the allow list. If not: drop the call<br>
2. Bringing together the legs: the actually used codec list on each leg only contains the codecs supported by the respective device and which are allowed on the allow list on the<br>
other hand.<br>
3. At this point Asterisk decides: if there are common codecs on both legs -> use these / this. If there are no common codecs between two legs: transcode (Use case: don't prevent a<br>
call as long as the codecs on each leg itself are allowed).<br>
4. Each phone on each call leg may define its own codec order. But Asterisk finally has to decide, which side to prefer (-> switchable).<br>
5. Basically, a phone mustn't advertise codecs it can't handle - if this can't be prevented, the codec has to be removed on the respective allow list of the line on Asterisk side.<br>
<br>
[...]<br>
<br>
> Simple use case, Alice to Bob, no direct media.<br>
> <br>
> 1. Under what conditions would we accept a format on an incoming offer<br>
> from a UAC (Alice) that *wasn't* in the UAC's endpoint allow= parameter?<br>
<br>
The use case of this consideration seems to me: How to handle broken configurations.<br>
<br>
> Does whether we accept formats not on the endpoint need to be<br>
> configurable? Don't just say "yes". :)<br>
<br>
No. From my point of view it never ever is Asterisk's job to handle broken configurations. Simple example: Phone sends SDP offer codec a) and b) which are both not on the allow list<br>
for this endpoint -> drop the call.<br>
<br>
> We need use cases.<br>
<br>
Use case: It's not Asterisk's job to repair broken configurations. I must be sure that only allowed codecs are used on a defined port because of bandwidth restrictions e.g.<br>
<br>
> We could<br>
> use the offer's list exclusively, use the endpoint's list exclusively,<br>
> merge the two together, or use only those in common.<br>
<br>
Asterisk finally defines which codec to use. Therefore all codecs of the phones offer have to be dropped which are not part of the allow list. Furthermore all codecs of the allow<br>
list have to be dropped, which are not contained in the SDP offer of the device.<br>
<br>
> What happens if after<br>
> applying that operation, there are no formats in common? Drop the call?<br>
<br>
Exactly. Because it's a result of misconfiguration. It's not Asterisk's job to repair broken configurations.<br>
<br>
> Transocde? <br>
<br>
Transcoding only if there is an allowed and supported codec on both sides which are not common. If there is one common codec on both sides - use this codec and do not transcode.<br>
<br>
> Using what format? It'd have to be one Alice accepts. We'll<br>
> save the process of transcoding for a follow-on discussion.<br>
> <br>
> 2. Under what conditions would we send a codec in an offer to a UAS (Bob)<br>
> that *wasn't* in the UAS's endpoint allow= parameter.<br>
<br>
Never! I must be sure about the codecs to be used on a line (bandwidth).<br>
<br>
> Similarly, under<br>
> what conditions would we send a format to Bob that *was* in his endpoint<br>
> allow= parameter but *wasn't* in the reconciled list we got from Alice via<br>
> the core? Same possible options and questions as above.<br>
<br>
Asterisk just should send the codecs to Bob which are part of the allow list - nothing more. The order could be defined by the reconciled list we got from Alice. Always the same use<br>
case: Asterisk defines which codec to use just to be sure that bandwidth requirements can be enforced (or other requirements)<br>
<br>
> <br>
> 3. OK now whatever we've decided to send to Bob, according to RFC3264 para<br>
> 6.1, Bob MUST send back an answer that contains a common format OR reject<br>
> the stream if there are no formats in common. It doesn't say whether it's<br>
> valid for Bob to send back formats we didn't request *in addition *to ones<br>
> we did request. It wouldn't make sense for him to do that because that<br>
> same RFC and paragraph only says we MUST accept media in a format we sent.<br>
> It doesn't mention what should happen if we get media in a format we<br>
> *didn't* request. Based on this, unless someone can give us a valid use<br>
> case for this, and rules governing when it's acceptable and when it's not,<br>
> we do NOT plan on supporting receiving media in a format we didn't<br>
> request.<br>
<br>
Yes.<br>
<br>
> We'd just drop the frames.<br>
<br>
Correctly.<br>
<br>
> If Bob wants to use a format not in<br>
> the offer, he should RE-INVITE.<br>
<br>
Which would lead to a drop - remember: we don't allow any codec not on the allow list.<br>
<br>
> <br>
> 4. Now we've got Bob's answer and are passing it back to the core so we<br>
> need to send an answer back to Alice.<br>
<br>
All codecs not on Bob's allow list have to be removed. The order may be adopted.<br>
<br>
> First, unless someone can give us a<br>
> valid use case, we will never send Alice a format she didn't request in her<br>
> offer so those will get removed.<br>
<br>
Correct. Furthermore, you mustn't send any format which is not part of Alice's allow list.<br>
<br>
> Based on options specified above though,<br>
> the potential answer MAY contain formats NOT in Alice's endpoint allow=<br>
> parameter. Same options and questions as "1".<br>
<br>
No - the answer mustn't contain any format not allowed in the allow list. It's the allow list which finally defines codecs to be used. I must count on the allow list!<br>
<br>
> <br>
> Now let's talk about format preference order.<br>
> <br>
> On the Alice to Bob side...<br>
> 1. On Alice's incoming leg, after reconciling Alice's offer and Alice's<br>
> endpoint, we can sort by Alice's preferred order or Alice's endpoint's<br>
> preferred order based on configuration and send that order to the core.<br>
<br>
The order can be defined by the phone based on the allowed codecs. That's ok for me. It's just important to remove each codec which is not on the allow list.<br>
<br>
> 2. On Bob's outgoing leg, after reconciling what came from the core and<br>
> Bob's endpoint, we can also sort based on either and send that in the offer.<br>
<br>
Based on the fact, that only the allowed codecs are contained in the offer and furthermore based on the fact, that each phone must be able to handle the codecs it advertises /<br>
accepts -> fine with me.<br>
<br>
> 3. Bob can re-order the formats in his answer so I guess we need another<br>
> option to use the order we sent or the order we received before we send it<br>
> back to the core. Do we care about the order we got *from* the core or on<br>
> Bob's endpoint any more? Hopefully not.<br>
<br>
No - keep the formats based on the received order - but remove the not allowed codecs.<br>
<br>
> 4. Now we've got a list from the core and we need to send an answer back<br>
> to Alice... Do we need any sort alterations at all here or can we just use<br>
> what came from the core?<br>
<br>
Goal is to find a codec supported by both just to prevent transcoding. Therefore use the first codec based on the order of the initial call of Alice. If there is no common codec -><br>
transcode between the first codec in the list on both lines.<br>
<br>
> One more thing to consider... Alice and Bob may *not* both be using a<br>
> pjsip channel. In this case, the process can only be applied on the call<br>
> leg that *is* pjsip. Let's say that Alice's leg is pjsip and Bob's isn't.<br>
> We can make Alice's channel aware that Bob isn't capable of the advanced<br>
> codec process but only after Bob's channel has been created so the process<br>
> Alice runs when passing the list to the core won't know. The process that<br>
> runs when constructing Alice's answer *will* know by virtue of *not getting<br>
> anything* from the core because today there's no feedback at all from the<br>
> core. On the flip side, if Alice is chan_sip and Bob is chan_pjsip, Bob<br>
> *will* know whether what came from the core is "advanced" or not. Now the<br>
> question is, given all that's talked about above, do the rules change<br>
> depending on whether both channels are pjsip or not? Of course, if<br>
> *neither* is pjsip, none of the above applies and the old process is used.<br>
<br>
I would say: The new process can be used only if all call legs are ruled by pjsip. If one call leg is not ruled by pjsip -> use the traditional process.<br>
<br>
> <br>
> I know this is a lot to take in but I'd implore you to read thoroughly,<br>
> respond with real life scenarios and ask questions if something isn't<br>
> clear. We are NOT going to shove this into 18 without everyone<br>
> understanding the implications, and if the process gets too complex, we'll<br>
> NEVER put it in because it'll work no better and be no better understood<br>
> than the current process.<br>
<br>
Well, there must be principles as written above. If those are kept, I can't see any problem at the moment - it seems to me pretty simple.<br>
<br>
<br>
Some examples:<br>
<br>
1) Drop call<br>
Alice: g722/g711<br>
<br>
Asterisk allow: g729<br>
<br>
=> all calls from and to Alice will be dropped. It's just a misconfiguration -> admins fault. It's not the job of asterisk to repair it.<br>
<br>
<br>
2) Prevent transcoding<br>
Alice: g722/g711<br>
<br>
------------------------------------<br>
Asterisk Alice allow: g729/g711/g722<br>
<br>
Asterisk Bob allow: g722/g711/g726<br>
------------------------------------<br>
<br>
Bob: gsm/g729/g711/g722<br>
<br>
Alice calls Bob:<br>
- Asterisk drops g729 on the possible list of used codecs for this call leg based on the offer of Alice.<br>
- Asterisk sends to Bob: g722/g711/g726 (it's always Bobs allow list based on the order of Alice's offer)<br>
<br>
- Bob sends to Asterisk: gsm/g729/g711/g722 - Asterisk drops gsm and g729 (because not on the allow list). g711/g722 is given to the core to compare and find the chosen codec: Result<br>
will be: g722 (based on the order of the incoming call leg g722/g711). If you would have preferred the outgoing call leg, the resulting common codec would have been g711.<br>
<br>
<br>
3) Transcoding example<br>
Alice: g729<br>
<br>
------------------------------------<br>
Asterisk Alice allow: g722/g711/g729<br>
<br>
Asterisk Bob allow: g722/g711<br>
------------------------------------<br>
<br>
Bob: gsm/g729/g711/g722<br>
<br>
Alice calls Bob:<br>
- Asterisk drops g711/g729 on the possible list of used codecs for this call leg based on the offer of Alice.<br>
- Asterisk sends to Bob: g722/g711 (it's always Bobs allow list based on the order of Alice's offer - if possible :-))<br>
- Bob sends to Asterisk: gsm/g729/g711/g722 - Asterisk drops gsm and g729 (because not on the allow list). g711/g722 is given to the core to compare and find the chosen codec: In<br>
this case, the call is transcoded between g729 and g711 (because there is no common codec between both call legs and transcoding usually is better than dropping - but this decision<br>
may be switchable).<br>
<br>
<br>
Hope this helps!<br>
<br>
<br>
Thanks<br>
Kind regards<br>
Michael<br>
<br>
<br>
[1] <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Codec+Negotiation+Proposal" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki/display/AST/Asterisk+18+Codec+Negotiation+Proposal</a><br>
<br>
-- <br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" rel="noreferrer" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr" style="font-size:12.8px"><div dir="ltr" style="font-size:12.8px"><div style="font-family:tahoma,sans-serif;font-size:small"><span style="color:rgb(7,55,99)">George Joseph</span><br></div></div><div dir="ltr" style="font-size:small"></div><div style="font-family:tahoma,sans-serif;font-size:small"><span style="color:rgb(7,55,99)">Asterisk Software Developer</span><br></div><span style="color:rgb(7,55,99);font-family:tahoma,sans-serif;font-size:small">direct/fax +1 256 428 6012</span><br><div style="font-family:tahoma,sans-serif;font-size:small"><font color="#073763" style="--darkreader-inline-color:#97cdf8;">Check us out at</font> <a href="http://www.sangoma.com/" style="color:rgb(17,85,204)" target="_blank">www.sangoma.com</a> and <a href="http://www.asterisk.org" target="_blank">www.asterisk.org</a><br></div><div style="font-family:tahoma,sans-serif;font-size:small"><img src="cid:ii_k3abte590" alt="image.png" width="184" height="32" style="margin-right: 0px;"></div></div></div></div></div></div></div></div></div>