Asterisk - The Open Source Telephony Project  18.5.0
format_cache.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Joshua Colp <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  *
21  * \brief Media Format Cache API
22  *
23  * \author Joshua Colp <[email protected]>
24  */
25 
26 /*** MODULEINFO
27  <support_level>core</support_level>
28  ***/
29 
30 #include "asterisk.h"
31 
32 #include "asterisk/logger.h"
33 #include "asterisk/format.h"
34 #include "asterisk/format_cache.h"
35 #include "asterisk/astobj2.h"
36 #include "asterisk/strings.h"
37 
38 /*!
39  * \brief Built-in cached signed linear 8kHz format.
40  */
42 
43 /*!
44  * \brief Built-in cached signed linear 12kHz format.
45  */
47 
48 /*!
49  * \brief Built-in cached signed linear 16kHz format.
50  */
52 
53 /*!
54  * \brief Built-in cached signed linear 24kHz format.
55  */
57 
58 /*!
59  * \brief Built-in cached signed linear 32kHz format.
60  */
62 
63 /*!
64  * \brief Built-in cached signed linear 44kHz format.
65  */
67 
68 /*!
69  * \brief Built-in cached signed linear 48kHz format.
70  */
72 
73 /*!
74  * \brief Built-in cached signed linear 96kHz format.
75  */
77 
78 /*!
79  * \brief Built-in cached signed linear 192kHz format.
80  */
82 
83 /*!
84  * \brief Built-in cached ulaw format.
85  */
87 
88 /*!
89  * \brief Built-in cached alaw format.
90  */
92 
93 /*!
94  * \brief Built-in cached testlaw format.
95  */
97 
98 /*!
99  * \brief Built-in cached gsm format.
100  */
102 
103 /*!
104  * \brief Built-in cached adpcm format.
105  */
107 
108 /*!
109  * \brief Built-in cached g722 format.
110  */
112 
113 /*!
114  * \brief Built-in cached g726 format.
115  */
117 
118 /*!
119  * \brief Built-in cached g726-aal2 format.
120  */
122 
123 /*!
124  * \brief Built-in cached ilbc format.
125  */
127 
128 /*!
129  * \brief Built-in cached ilbc format.
130  */
132 
133 /*!
134  * \brief Built-in cached speex format.
135  */
137 
138 /*!
139  * \brief Built-in cached speex at 16kHz format.
140  */
142 
143 /*!
144  * \brief Built-in cached speex at 32kHz format.
145  */
147 
148 /*!
149  * \brief Built-in cached g723.1 format.
150  */
152 
153 /*!
154  * \brief Built-in cached g729 format.
155  */
157 
158 /*!
159  * \brief Built-in cached g719 format.
160  */
162 
163 /*!
164  * \brief Built-in cached h261 format.
165  */
167 
168 /*!
169  * \brief Built-in cached h263 format.
170  */
172 
173 /*!
174  * \brief Built-in cached h263 plus format.
175  */
177 
178 /*!
179  * \brief Built-in cached h264 format.
180  */
182 
183 /*!
184  * \brief Built-in cached h265 format.
185  */
187 
188 /*!
189  * \brief Built-in cached mp4 format.
190  */
192 
193 /*!
194  * \brief Built-in cached vp8 format.
195  */
197 
198 /*!
199  * \brief Built-in cached vp9 format.
200  */
202 
203 /*!
204  * \brief Built-in cached jpeg format.
205  */
207 
208 /*!
209  * \brief Built-in cached png format.
210  */
212 
213 /*!
214  * \brief Built-in cached siren14 format.
215  */
217 
218 /*!
219  * \brief Built-in cached siren7 format.
220  */
222 
223 /*!
224  * \brief Built-in cached opus format.
225  */
227 
228 /*!
229  * \brief Built-in cached codec2 format.
230  */
232 
233 /*!
234  * \brief Built-in cached t140 format.
235  */
237 
238 /*!
239  * \brief Built-in cached t140 red format.
240  */
242 
243 /*!
244  * \brief Built-in cached T.38 format.
245  */
247 
248 /*!
249  * \brief Built-in "null" format.
250  */
252 
253 /*!
254  * \brief Built-in "silk" format
255  */
260 
261 /*! \brief Number of buckets to use for the media format cache (should be prime for performance reasons) */
262 #define CACHE_BUCKETS 53
263 
264 /*! \brief Cached formats */
265 static struct ao2_container *formats;
266 
267 static int format_hash_cb(const void *obj, int flags)
268 {
269  const struct ast_format *format;
270  const char *key;
271 
272  switch (flags & OBJ_SEARCH_MASK) {
273  case OBJ_SEARCH_KEY:
274  key = obj;
275  return ast_str_case_hash(key);
276  case OBJ_SEARCH_OBJECT:
277  format = obj;
278  return ast_str_case_hash(ast_format_get_name(format));
279  default:
280  /* Hash can only work on something with a full key. */
281  ast_assert(0);
282  return 0;
283  }
284 }
285 
286 static int format_cmp_cb(void *obj, void *arg, int flags)
287 {
288  const struct ast_format *left = obj;
289  const struct ast_format *right = arg;
290  const char *right_key = arg;
291  int cmp;
292 
293  switch (flags & OBJ_SEARCH_MASK) {
294  case OBJ_SEARCH_OBJECT:
295  right_key = ast_format_get_name(right);
296  /* Fall through */
297  case OBJ_SEARCH_KEY:
298  cmp = strcasecmp(ast_format_get_name(left), right_key);
299  break;
301  cmp = strncasecmp(ast_format_get_name(left), right_key, strlen(right_key));
302  break;
303  default:
304  ast_assert(0);
305  cmp = 0;
306  break;
307  }
308  if (cmp) {
309  return 0;
310  }
311 
312  return CMP_MATCH;
313 }
314 
315 /*! \brief Function called when the process is shutting down */
316 static void format_cache_shutdown(void)
317 {
318  ao2_cleanup(formats);
319  formats = NULL;
320 
321  ao2_replace(ast_format_g723, NULL);
322  ao2_replace(ast_format_ulaw, NULL);
323  ao2_replace(ast_format_alaw, NULL);
324  ao2_replace(ast_format_gsm, NULL);
325  ao2_replace(ast_format_g726, NULL);
326  ao2_replace(ast_format_g726_aal2, NULL);
327  ao2_replace(ast_format_adpcm, NULL);
328  ao2_replace(ast_format_slin, NULL);
329  ao2_replace(ast_format_slin12, NULL);
330  ao2_replace(ast_format_slin16, NULL);
331  ao2_replace(ast_format_slin24, NULL);
332  ao2_replace(ast_format_slin32, NULL);
333  ao2_replace(ast_format_slin44, NULL);
334  ao2_replace(ast_format_slin48, NULL);
335  ao2_replace(ast_format_slin96, NULL);
336  ao2_replace(ast_format_slin192, NULL);
337  ao2_replace(ast_format_lpc10, NULL);
338  ao2_replace(ast_format_g729, NULL);
339  ao2_replace(ast_format_speex, NULL);
340  ao2_replace(ast_format_speex16, NULL);
341  ao2_replace(ast_format_speex32, NULL);
342  ao2_replace(ast_format_ilbc, NULL);
343  ao2_replace(ast_format_g722, NULL);
344  ao2_replace(ast_format_siren7, NULL);
345  ao2_replace(ast_format_siren14, NULL);
346  ao2_replace(ast_format_testlaw, NULL);
347  ao2_replace(ast_format_g719, NULL);
348  ao2_replace(ast_format_opus, NULL);
349  ao2_replace(ast_format_codec2, NULL);
350  ao2_replace(ast_format_jpeg, NULL);
351  ao2_replace(ast_format_png, NULL);
352  ao2_replace(ast_format_h261, NULL);
353  ao2_replace(ast_format_h263, NULL);
354  ao2_replace(ast_format_h263p, NULL);
355  ao2_replace(ast_format_h264, NULL);
356  ao2_replace(ast_format_h265, NULL);
357  ao2_replace(ast_format_mp4, NULL);
358  ao2_replace(ast_format_vp8, NULL);
359  ao2_replace(ast_format_vp9, NULL);
360  ao2_replace(ast_format_t140_red, NULL);
361  ao2_replace(ast_format_t140, NULL);
362  ao2_replace(ast_format_t38, NULL);
363  ao2_replace(ast_format_none, NULL);
364  ao2_replace(ast_format_silk8, NULL);
365  ao2_replace(ast_format_silk12, NULL);
366  ao2_replace(ast_format_silk16, NULL);
367  ao2_replace(ast_format_silk24, NULL);
368 }
369 
371 {
374  if (!formats) {
375  return -1;
376  }
377 
379 
380  return 0;
381 }
382 
383 static void set_cached_format(const char *name, struct ast_format *format)
384 {
385  if (!strcmp(name, "codec2")) {
386  ao2_replace(ast_format_codec2, format);
387  } else if (!strcmp(name, "g723")) {
388  ao2_replace(ast_format_g723, format);
389  } else if (!strcmp(name, "ulaw")) {
390  ao2_replace(ast_format_ulaw, format);
391  } else if (!strcmp(name, "alaw")) {
392  ao2_replace(ast_format_alaw, format);
393  } else if (!strcmp(name, "gsm")) {
394  ao2_replace(ast_format_gsm, format);
395  } else if (!strcmp(name, "g726")) {
396  ao2_replace(ast_format_g726, format);
397  } else if (!strcmp(name, "g726aal2")) {
398  ao2_replace(ast_format_g726_aal2, format);
399  } else if (!strcmp(name, "adpcm")) {
400  ao2_replace(ast_format_adpcm, format);
401  } else if (!strcmp(name, "slin")) {
402  ao2_replace(ast_format_slin, format);
403  } else if (!strcmp(name, "slin12")) {
404  ao2_replace(ast_format_slin12, format);
405  } else if (!strcmp(name, "slin16")) {
406  ao2_replace(ast_format_slin16, format);
407  } else if (!strcmp(name, "slin24")) {
408  ao2_replace(ast_format_slin24, format);
409  } else if (!strcmp(name, "slin32")) {
410  ao2_replace(ast_format_slin32, format);
411  } else if (!strcmp(name, "slin44")) {
412  ao2_replace(ast_format_slin44, format);
413  } else if (!strcmp(name, "slin48")) {
414  ao2_replace(ast_format_slin48, format);
415  } else if (!strcmp(name, "slin96")) {
416  ao2_replace(ast_format_slin96, format);
417  } else if (!strcmp(name, "slin192")) {
418  ao2_replace(ast_format_slin192, format);
419  } else if (!strcmp(name, "lpc10")) {
420  ao2_replace(ast_format_lpc10, format);
421  } else if (!strcmp(name, "g729")) {
422  ao2_replace(ast_format_g729, format);
423  } else if (!strcmp(name, "speex")) {
424  ao2_replace(ast_format_speex, format);
425  } else if (!strcmp(name, "speex16")) {
426  ao2_replace(ast_format_speex16, format);
427  } else if (!strcmp(name, "speex32")) {
428  ao2_replace(ast_format_speex32, format);
429  } else if (!strcmp(name, "ilbc")) {
430  ao2_replace(ast_format_ilbc, format);
431  } else if (!strcmp(name, "g722")) {
432  ao2_replace(ast_format_g722, format);
433  } else if (!strcmp(name, "siren7")) {
434  ao2_replace(ast_format_siren7, format);
435  } else if (!strcmp(name, "siren14")) {
436  ao2_replace(ast_format_siren14, format);
437  } else if (!strcmp(name, "testlaw")) {
438  ao2_replace(ast_format_testlaw, format);
439  } else if (!strcmp(name, "g719")) {
440  ao2_replace(ast_format_g719, format);
441  } else if (!strcmp(name, "opus")) {
442  ao2_replace(ast_format_opus, format);
443  } else if (!strcmp(name, "jpeg")) {
444  ao2_replace(ast_format_jpeg, format);
445  } else if (!strcmp(name, "png")) {
446  ao2_replace(ast_format_png, format);
447  } else if (!strcmp(name, "h261")) {
448  ao2_replace(ast_format_h261, format);
449  } else if (!strcmp(name, "h263")) {
450  ao2_replace(ast_format_h263, format);
451  } else if (!strcmp(name, "h263p")) {
452  ao2_replace(ast_format_h263p, format);
453  } else if (!strcmp(name, "h264")) {
454  ao2_replace(ast_format_h264, format);
455  } else if (!strcmp(name, "h265")) {
456  ao2_replace(ast_format_h265, format);
457  } else if (!strcmp(name, "mpeg4")) {
458  ao2_replace(ast_format_mp4, format);
459  } else if (!strcmp(name, "vp8")) {
460  ao2_replace(ast_format_vp8, format);
461  } else if (!strcmp(name, "vp9")) {
462  ao2_replace(ast_format_vp9, format);
463  } else if (!strcmp(name, "red")) {
464  ao2_replace(ast_format_t140_red, format);
465  } else if (!strcmp(name, "t140")) {
466  ao2_replace(ast_format_t140, format);
467  } else if (!strcmp(name, "t38")) {
468  ao2_replace(ast_format_t38, format);
469  } else if (!strcmp(name, "none")) {
470  ao2_replace(ast_format_none, format);
471  } else if (!strcmp(name, "silk8")) {
472  ao2_replace(ast_format_silk8, format);
473  } else if (!strcmp(name, "silk12")) {
474  ao2_replace(ast_format_silk12, format);
475  } else if (!strcmp(name, "silk16")) {
476  ao2_replace(ast_format_silk16, format);
477  } else if (!strcmp(name, "silk24")) {
478  ao2_replace(ast_format_silk24, format);
479  }
480 }
481 
483 {
484  SCOPED_AO2WRLOCK(lock, formats);
485  struct ast_format *old_format;
486 
487  ast_assert(format != NULL);
488 
489  if (ast_strlen_zero(ast_format_get_name(format))) {
490  return -1;
491  }
492 
493  old_format = ao2_find(formats, ast_format_get_name(format), OBJ_SEARCH_KEY | OBJ_NOLOCK);
494  if (old_format) {
495  ao2_unlink_flags(formats, old_format, OBJ_NOLOCK);
496  }
497  ao2_link_flags(formats, format, OBJ_NOLOCK);
498 
499  set_cached_format(ast_format_get_name(format), format);
500 
501  ast_verb(2, "%s cached format with name '%s'\n",
502  old_format ? "Updated" : "Created",
503  ast_format_get_name(format));
504 
505  ao2_cleanup(old_format);
506 
507  return 0;
508 }
509 
511  const char *tag, const char *file, int line, const char *func)
512 {
513  if (ast_strlen_zero(name)) {
514  return NULL;
515  }
516 
517  return __ao2_find(formats, name, OBJ_SEARCH_KEY, tag, file, line, func);
518 }
519 
521 {
522  if (rate >= 192000) {
523  return ast_format_slin192;
524  } else if (rate >= 96000) {
525  return ast_format_slin96;
526  } else if (rate >= 48000) {
527  return ast_format_slin48;
528  } else if (rate >= 44100) {
529  return ast_format_slin44;
530  } else if (rate >= 32000) {
531  return ast_format_slin32;
532  } else if (rate >= 24000) {
533  return ast_format_slin24;
534  } else if (rate >= 16000) {
535  return ast_format_slin16;
536  } else if (rate >= 12000) {
537  return ast_format_slin12;
538  }
539  return ast_format_slin;
540 }
541 
543 {
544  if ((ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL)
545  || (ast_format_cmp(format, ast_format_slin12) == AST_FORMAT_CMP_EQUAL)
546  || (ast_format_cmp(format, ast_format_slin16) == AST_FORMAT_CMP_EQUAL)
547  || (ast_format_cmp(format, ast_format_slin24) == AST_FORMAT_CMP_EQUAL)
548  || (ast_format_cmp(format, ast_format_slin32) == AST_FORMAT_CMP_EQUAL)
549  || (ast_format_cmp(format, ast_format_slin44) == AST_FORMAT_CMP_EQUAL)
550  || (ast_format_cmp(format, ast_format_slin48) == AST_FORMAT_CMP_EQUAL)
551  || (ast_format_cmp(format, ast_format_slin96) == AST_FORMAT_CMP_EQUAL)
552  || (ast_format_cmp(format, ast_format_slin192) == AST_FORMAT_CMP_EQUAL)) {
553  return 1;
554  }
555 
556  return 0;
557 }
558 
560 {
561  struct ast_format *format;
562  struct ao2_iterator it;
563 
564  for (it = ao2_iterator_init(formats, 0);
565  (format = ao2_iterator_next(&it));
566  ao2_ref(format, -1)) {
567  struct ast_codec *candidate = ast_format_get_codec(format);
568  if (codec == candidate) {
569  ao2_cleanup(candidate);
571  return format;
572  }
573  ao2_cleanup(candidate);
574  }
575 
577  return NULL;
578 }
struct ast_format * ast_format_slin192
Built-in cached signed linear 192kHz format.
Definition: format_cache.c:81
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
Asterisk main include file. File version handling, generic pbx functions.
struct ast_codec * ast_format_get_codec(const struct ast_format *format)
Get the codec associated with a format.
Definition: format.c:324
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.
Definition: astobj2.h:1105
struct ast_format * ast_format_ilbc
Built-in cached ilbc format.
Definition: format_cache.c:126
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:542
struct ast_format * ast_format_mp4
Built-in cached mp4 format.
Definition: format_cache.c:191
struct ast_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:236
struct ast_format * ast_format_g722
Built-in cached g722 format.
Definition: format_cache.c:111
struct ast_format * ast_format_h265
Built-in cached h265 format.
Definition: format_cache.c:186
struct ast_format * ast_format_slin96
Built-in cached signed linear 96kHz format.
Definition: format_cache.c:76
struct ast_format * ast_format_t140_red
Built-in cached t140 red format.
Definition: format_cache.c:241
struct ast_format * ast_format_h261
Built-in cached h261 format.
Definition: format_cache.c:166
struct ast_format * ast_format_vp9
Built-in cached vp9 format.
Definition: format_cache.c:201
Assume that the ao2_container is already locked.
Definition: astobj2.h:1067
struct ast_format * __ast_format_cache_get(const char *name, const char *tag, const char *file, int line, const char *func)
Retrieve a named format from the cache.
Definition: format_cache.c:510
static void format_cache_shutdown(void)
Function called when the process is shutting down.
Definition: format_cache.c:316
Definition of a media format.
Definition: format.c:43
struct ast_format * ast_format_jpeg
Built-in cached jpeg format.
Definition: format_cache.c:206
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_assert(a)
Definition: utils.h:695
#define ao2_link_flags(container, obj, flags)
Definition: astobj2.h:1572
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
struct ast_format * ast_format_slin32
Built-in cached signed linear 32kHz format.
Definition: format_cache.c:61
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:251
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:156
#define NULL
Definition: resample.c:96
struct ast_format * ast_format_opus
Built-in cached opus format.
Definition: format_cache.c:226
struct ast_format * ast_format_cache_get_by_codec(const struct ast_codec *codec)
Retrieve a format from the cache by its codec.
Definition: format_cache.c:559
int ast_format_cache_init(void)
Initialize format cache support within the core.
Definition: format_cache.c:370
#define ast_verb(level,...)
Definition: logger.h:463
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:171
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:101
#define SCOPED_AO2WRLOCK(varname, obj)
scoped lock specialization for ao2 write locks.
Definition: lock.h:612
Media Format API.
#define ast_strlen_zero(foo)
Definition: strings.h:52
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
Definition: astobj2.h:1120
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
struct ast_format * ast_format_h263p
Built-in cached h263 plus format.
Definition: format_cache.c:176
#define CACHE_BUCKETS
Number of buckets to use for the media format cache (should be prime for performance reasons) ...
Definition: format_cache.c:262
struct ast_format * ast_format_adpcm
Built-in cached adpcm format.
Definition: format_cache.c:106
struct ast_format * ast_format_testlaw
Built-in cached testlaw format.
Definition: format_cache.c:96
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
struct ast_format * ast_format_siren14
Built-in cached siren14 format.
Definition: format_cache.c:216
ast_mutex_t lock
Definition: app_meetme.c:1091
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct ao2_container * formats
Cached formats.
Definition: format_cache.c:265
struct ast_format * ast_format_h264
Built-in cached h264 format.
Definition: format_cache.c:181
struct ast_format * ast_format_silk12
Definition: format_cache.c:257
struct ast_format * ast_format_silk8
Built-in "silk" format.
Definition: format_cache.c:256
struct ast_format * ast_format_cache_get_slin_by_rate(unsigned int rate)
Retrieve the best signed linear format given a sample rate.
Definition: format_cache.c:520
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
static void set_cached_format(const char *name, struct ast_format *format)
Definition: format_cache.c:383
struct ast_codec * codec
Pointer to the codec in use for this format.
Definition: format.c:47
int ast_format_cache_set(struct ast_format *format)
Set a named format cache entry.
Definition: format_cache.c:482
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
struct ast_format * ast_format_speex16
Built-in cached speex at 16kHz format.
Definition: format_cache.c:141
struct ast_format * ast_format_png
Built-in cached png format.
Definition: format_cache.c:211
static const char name[]
Definition: cdr_mysql.c:74
struct ast_format * ast_format_slin24
Built-in cached signed linear 24kHz format.
Definition: format_cache.c:56
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
static int format_cmp_cb(void *obj, void *arg, int flags)
Definition: format_cache.c:286
struct ast_format * ast_format_slin48
Built-in cached signed linear 48kHz format.
Definition: format_cache.c:71
Support for logging to various files, console and syslog Configuration in file logger.conf.
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_speex32
Built-in cached speex at 32kHz format.
Definition: format_cache.c:146
The arg parameter is an object of the same type.
Definition: astobj2.h:1091
#define ao2_replace(dst, src)
Definition: astobj2.h:517
struct ast_format * ast_format_lpc10
Built-in cached ilbc format.
Definition: format_cache.c:131
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ast_format * ast_format_silk16
Definition: format_cache.c:258
struct ast_format * ast_format_t38
Built-in cached T.38 format.
Definition: format_cache.c:246
struct ast_format * ast_format_g726_aal2
Built-in cached g726-aal2 format.
Definition: format_cache.c:121
struct ast_format * ast_format_siren7
Built-in cached siren7 format.
Definition: format_cache.c:221
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:136
#define ao2_unlink_flags(container, obj, flags)
Definition: astobj2.h:1622
static int format_hash_cb(const void *obj, int flags)
Definition: format_cache.c:267
Generic container type.
Search option field mask.
Definition: astobj2.h:1076
struct ast_format * ast_format_slin16
Built-in cached signed linear 16kHz format.
Definition: format_cache.c:51
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:151
struct ast_format * ast_format_codec2
Built-in cached codec2 format.
Definition: format_cache.c:231
static snd_pcm_format_t format
Definition: chan_alsa.c:102
Represents a media codec within Asterisk.
Definition: codec.h:42
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct ast_format * ast_format_g719
Built-in cached g719 format.
Definition: format_cache.c:161
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
struct ast_format * ast_format_vp8
Built-in cached vp8 format.
Definition: format_cache.c:196
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Definition: strings.h:1250
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:116
Media Format Cache API.
struct ast_format * ast_format_silk24
Definition: format_cache.c:259
struct ast_format * ast_format_slin44
Built-in cached signed linear 44kHz format.
Definition: format_cache.c:66
struct ast_format * ast_format_slin12
Built-in cached signed linear 12kHz format.
Definition: format_cache.c:46