mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-23 14:44:28 +00:00
format_cap: Perform codec lookups by pointer instead of name
ASTERISK-28416 #close Change-Id: I069420875ebdbcaada52d92599a5f7de3cb2cdf4
This commit is contained in:
committed by
George Joseph
parent
53910b1f25
commit
30e08ce1bb
@@ -555,3 +555,24 @@ int ast_format_cache_is_slinear(struct ast_format *format)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ast_format *ast_format_cache_get_by_codec(const struct ast_codec *codec)
|
||||
{
|
||||
struct ast_format *format;
|
||||
struct ao2_iterator it;
|
||||
|
||||
for (it = ao2_iterator_init(formats, 0);
|
||||
(format = ao2_iterator_next(&it));
|
||||
ao2_ref(format, -1)) {
|
||||
struct ast_codec *candidate = ast_format_get_codec(format);
|
||||
if (codec == candidate) {
|
||||
ao2_cleanup(candidate);
|
||||
ao2_iterator_destroy(&it);
|
||||
return format;
|
||||
}
|
||||
ao2_cleanup(candidate);
|
||||
}
|
||||
|
||||
ao2_iterator_destroy(&it);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user