257 #define CACHE_BUCKETS 53
262 static int format_hash_cb(
const void *obj,
int flags)
281 static int format_cmp_cb(
void *obj,
void *arg,
int flags)
285 const char *right_key = arg;
313 ao2_cleanup(formats);
367 format_hash_cb, NULL, format_cmp_cb);
377 static void set_cached_format(
const char *
name,
struct ast_format *format)
379 if (!strcmp(name,
"codec2")) {
381 }
else if (!strcmp(name,
"g723")) {
383 }
else if (!strcmp(name,
"ulaw")) {
385 }
else if (!strcmp(name,
"alaw")) {
387 }
else if (!strcmp(name,
"gsm")) {
389 }
else if (!strcmp(name,
"g726")) {
391 }
else if (!strcmp(name,
"g726aal2")) {
393 }
else if (!strcmp(name,
"adpcm")) {
395 }
else if (!strcmp(name,
"slin")) {
397 }
else if (!strcmp(name,
"slin12")) {
399 }
else if (!strcmp(name,
"slin16")) {
401 }
else if (!strcmp(name,
"slin24")) {
403 }
else if (!strcmp(name,
"slin32")) {
405 }
else if (!strcmp(name,
"slin44")) {
407 }
else if (!strcmp(name,
"slin48")) {
409 }
else if (!strcmp(name,
"slin96")) {
411 }
else if (!strcmp(name,
"slin192")) {
413 }
else if (!strcmp(name,
"lpc10")) {
415 }
else if (!strcmp(name,
"g729")) {
417 }
else if (!strcmp(name,
"speex")) {
419 }
else if (!strcmp(name,
"speex16")) {
421 }
else if (!strcmp(name,
"speex32")) {
423 }
else if (!strcmp(name,
"ilbc")) {
425 }
else if (!strcmp(name,
"g722")) {
427 }
else if (!strcmp(name,
"siren7")) {
429 }
else if (!strcmp(name,
"siren14")) {
431 }
else if (!strcmp(name,
"g719")) {
433 }
else if (!strcmp(name,
"opus")) {
435 }
else if (!strcmp(name,
"jpeg")) {
437 }
else if (!strcmp(name,
"png")) {
439 }
else if (!strcmp(name,
"h261")) {
441 }
else if (!strcmp(name,
"h263")) {
443 }
else if (!strcmp(name,
"h263p")) {
445 }
else if (!strcmp(name,
"h264")) {
447 }
else if (!strcmp(name,
"h265")) {
449 }
else if (!strcmp(name,
"mpeg4")) {
451 }
else if (!strcmp(name,
"vp8")) {
453 }
else if (!strcmp(name,
"vp9")) {
455 }
else if (!strcmp(name,
"red")) {
457 }
else if (!strcmp(name,
"t140")) {
459 }
else if (!strcmp(name,
"t38")) {
461 }
else if (!strcmp(name,
"none")) {
463 }
else if (!strcmp(name,
"silk8")) {
465 }
else if (!strcmp(name,
"silk12")) {
467 }
else if (!strcmp(name,
"silk16")) {
469 }
else if (!strcmp(name,
"silk24")) {
479 ast_assert(format != NULL);
493 ast_verb(5,
"%s cached format with name '%s'\n",
494 old_format ?
"Updated" :
"Created",
497 ao2_cleanup(old_format);
502 struct ast_format *__ast_format_cache_get(
const char *name,
503 const char *tag,
const char *file,
int line,
const char *func)
505 if (ast_strlen_zero(name)) {
514 if (rate >= 192000) {
516 }
else if (rate >= 96000) {
518 }
else if (rate >= 48000) {
520 }
else if (rate >= 44100) {
522 }
else if (rate >= 32000) {
524 }
else if (rate >= 24000) {
526 }
else if (rate >= 16000) {
528 }
else if (rate >= 12000) {
557 (format = ao2_iterator_next(&it));
560 if (codec == candidate) {
561 ao2_cleanup(candidate);
565 ao2_cleanup(candidate);
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
void * __ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags, const char *tag, const char *file, int line, const char *func)
The arg parameter is a search key, but is not an object.
Assume that the ao2_container is already locked.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
#define SCOPED_AO2WRLOCK(varname, obj)
scoped lock specialization for ao2 write locks.
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Support for logging to various files, console and syslog Configuration in file logger.conf.
The arg parameter is an object of the same type.
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
#define ao2_unlink_flags(container, obj, flags)
Remove an object from a container.
Search option field mask.
Represents a media codec within Asterisk.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.