<div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">bridge_native_rtp up for review. One down, three hundred to go...<br><br>But onward anyway. Next on the "list": format attributes!<br><br>
The new specification calls for setting attributes using ast_format_set_attr, which takes in a key/value pair along with the format to set the attribute on. While this seems like the appropriate place to store the attribute (since the attribute describes the format), there's some problems with setting the attribute after format creation. Namely:<br>
<br></div><div class="gmail_extra">(1) A format object is immutable by convention. However, setting an attribute on a format is a mutable operation, which means we either (a) should set all attributes on format creation or (b) setting an attribute actually returns a copy of the format. Both of these approaches have drawbacks.<br>
<br></div><div class="gmail_extra">(2) Setting an attribute technically gets mapped back to a format attribute interface. This interface shouldn't require massive changes, but does need to be exposed through the format API as it generates the SDP attributes. How we expose that may need some tweaking, as ideally something using the format API won't care too much how it gets the SDP - just that it gets it.<br>
<br>:: Setting Attributes ::<br><br>The biggest sticky point is clearly #1. I don't think we should lose the immutability convention - that feels bad, since there's a lot of benefit to treating a format as a read-only object (no locking!) - and a format shouldn't change very often. In order to maintain mutability, I'd remove the public format attribute setting function and instead do the following:<br>
<br></div><div class="gmail_extra">(1) We set attributes only as the result of parsing an SDP. Currently, this is the only time we set attributes. ast_format_sdp_parse would be modified to return an ast_format. Calling that function should result in either NULL (failure) or a new ast_format, which should replace the format passed to the function (which would be the burden of the channel driver). Most of the work of duplicating the existing format and safely putting formats onto it could happen within format.c. In that case, there isn't much need for an individual 'add this format' function.<br>
<br></div><div class="gmail_extra">(2) Since the only time we add attributes is during SDP generation, there isn't any need for a public API that sets formats. The variable parameters that can be passed to ast_format_set are - from what I can tell - never passed.<br>
<br></div><div class="gmail_extra">(3) Producing the attributes is really just a matter of generating the SDP. This should be a public function in format.h that maps down to the attribute interface.<br><br></div><div class="gmail_extra">
:: Getting Attributes ::<br><br></div><div class="gmail_extra">Since the format is read-only, it's safe to get the format attributes from a format object. There is one place where this is done using ast_format_isset. ast_format_get_value is never used. As the object is immutable, a public accessor for an attribute key could be used that returns a const char *, which would fulfil both functions.<br>
<br></div><div class="gmail_extra">Thoughts? Flames?<br></div><div class="gmail_extra"><br>-- <br><div dir="ltr"><div>Matthew Jordan<br></div><div>Digium, Inc. | Engineering Manager</div><div>445 Jan Davis Drive NW - Huntsville, AL 35806 - USA</div>
<div>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></div>