[Asterisk-code-review] translate.c: Fixed codec translator bug (asterisk[master])

Kevin Harwell asteriskteam at digium.com
Tue Jun 1 15:47:13 CDT 2021


Attention is currently required from: N A.
Kevin Harwell has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/15953 )

Change subject: translate.c: Fixed codec translator bug
......................................................................


Patch Set 1: Code-Review-1

(3 comments)

File include/asterisk/translate.h:

https://gerrit.asterisk.org/c/asterisk/+/15953/comment/75c37abe_517f7676 
PS1, Line 285: /*! \brief Determine which protocol is higher quality
             :  *
             :  * Given two codec identifiers, is the first codec strictly superior to the second?
             :  *
             :  * \param codec identifier A
             :  * \param codec identifier B
             :  * \return Returns 1 if codec A is positively superior to B, 0 otherwise.
             :  */
             : int ast_translator_better_quality(int c1, int c2);
Since this function deals with choosing the best codec supplied by given formats I'd move this function to format.c/h or maybe format_compatibility.c/h? Although the latter has historically been for bitfield checks.


https://gerrit.asterisk.org/c/asterisk/+/15953/comment/de21a673_7bffa56c 
PS1, Line 293: int ast_translator_better_quality(int c1, int c2);
I'd pass in a pointer to the formats themselves, and then retrieve c1 & c2 within. Doing so makes it more obvious formats and codecs are being checked. Also makes it less likely an arbitrary value gets passed in.


File main/translate.c:

https://gerrit.asterisk.org/c/asterisk/+/15953/comment/e49352ac_64de1143 
PS1, Line 1499: 				} else if (gap_current == gap_selected) {
              : 					if (ast_translator_better_quality(
              : 						ast_format_get_codec_id(src), ast_format_get_codec_id(best))) {
I think if you wanted you could combine this with the above to reduce some code duplication?

if (gap_current < gap_selected || ((gap_current == gap_selected && ast_translator_better_quality(src, best))) { ....



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15953
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I4b7297e1baca7aac14fe4a3c7538e18e2dbe9fd6
Gerrit-Change-Number: 15953
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Attention: N A <mail at interlinked.x10host.com>
Gerrit-Comment-Date: Tue, 01 Jun 2021 20:47:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210601/7084ecb8/attachment.html>


More information about the asterisk-code-review mailing list