Asterisk - The Open Source Telephony Project GIT-master-a358458
format_cache.h
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 <jcolp@digium.com>
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/*!
20 * \file
21 * \brief Media Format Cache API
22 *
23 * \author Joshua Colp <jcolp@digium.com>
24 */
25
26#ifndef _AST_FORMAT_CACHE_H_
27#define _AST_FORMAT_CACHE_H_
28
29struct ast_format;
30
31/*!
32 * \brief Built-in cached signed linear 8kHz format.
33 */
34extern struct ast_format *ast_format_slin;
35
36/*!
37 * \brief Built-in cached signed linear 12kHz format.
38 */
39extern struct ast_format *ast_format_slin12;
40
41/*!
42 * \brief Built-in cached signed linear 16kHz format.
43 */
44extern struct ast_format *ast_format_slin16;
45
46/*!
47 * \brief Built-in cached signed linear 24kHz format.
48 */
49extern struct ast_format *ast_format_slin24;
50
51/*!
52 * \brief Built-in cached signed linear 32kHz format.
53 */
54extern struct ast_format *ast_format_slin32;
55
56/*!
57 * \brief Built-in cached signed linear 44kHz format.
58 */
59extern struct ast_format *ast_format_slin44;
60
61/*!
62 * \brief Built-in cached signed linear 48kHz format.
63 */
64extern struct ast_format *ast_format_slin48;
65
66/*!
67 * \brief Built-in cached signed linear 96kHz format.
68 */
69extern struct ast_format *ast_format_slin96;
70
71/*!
72 * \brief Built-in cached signed linear 192kHz format.
73 */
74extern struct ast_format *ast_format_slin192;
75
76/*!
77 * \brief Built-in cached ulaw format.
78 */
79extern struct ast_format *ast_format_ulaw;
80
81/*!
82 * \brief Built-in cached alaw format.
83 */
84extern struct ast_format *ast_format_alaw;
85
86/*!
87 * \brief Built-in cached gsm format.
88 */
89extern struct ast_format *ast_format_gsm;
90
91/*!
92 * \brief Built-in cached adpcm format.
93 */
94extern struct ast_format *ast_format_adpcm;
95
96/*!
97 * \brief Built-in cached g722 format.
98 */
99extern struct ast_format *ast_format_g722;
100
101/*!
102 * \brief Built-in cached g726 format.
103 */
104extern struct ast_format *ast_format_g726;
105
106/*!
107 * \brief Built-in cached g726 aal2 format.
108 */
109extern struct ast_format *ast_format_g726_aal2;
110
111/*!
112 * \brief Built-in cached ilbc format.
113 */
114extern struct ast_format *ast_format_ilbc;
115
116/*!
117 * \brief Built-in cached ilbc format.
118 */
119extern struct ast_format *ast_format_lpc10;
120
121/*!
122 * \brief Built-in cached speex format.
123 */
124extern struct ast_format *ast_format_speex;
125
126/*!
127 * \brief Built-in cached speex at 16kHz format.
128 */
129extern struct ast_format *ast_format_speex16;
130
131/*!
132 * \brief Built-in cached speex at 32kHz format.
133 */
134extern struct ast_format *ast_format_speex32;
135
136/*!
137 * \brief Built-in cached g723.1 format.
138 */
139extern struct ast_format *ast_format_g723;
140
141/*!
142 * \brief Built-in cached g729 format.
143 */
144extern struct ast_format *ast_format_g729;
145
146/*!
147 * \brief Built-in cached g719 format.
148 */
149extern struct ast_format *ast_format_g719;
150
151/*!
152 * \brief Built-in cached h261 format.
153 */
154extern struct ast_format *ast_format_h261;
155
156/*!
157 * \brief Built-in cached h263 format.
158 */
159extern struct ast_format *ast_format_h263;
160
161/*!
162 * \brief Built-in cached h263 plus format.
163 */
164extern struct ast_format *ast_format_h263p;
165
166/*!
167 * \brief Built-in cached h264 format.
168 */
169extern struct ast_format *ast_format_h264;
170
171/*!
172 * \brief Built-in cached h265 format.
173 */
174extern struct ast_format *ast_format_h265;
175
176/*!
177 * \brief Built-in cached mp4 format.
178 */
179extern struct ast_format *ast_format_mp4;
180
181/*!
182 * \brief Built-in cached vp8 format.
183 */
184extern struct ast_format *ast_format_vp8;
185
186/*!
187 * \brief Built-in cached vp9 format.
188 */
189extern struct ast_format *ast_format_vp9;
190
191/*!
192 * \brief Built-in cached jpeg format.
193 */
194extern struct ast_format *ast_format_jpeg;
195
196/*!
197 * \brief Built-in cached png format.
198 */
199extern struct ast_format *ast_format_png;
200
201/*!
202 * \brief Built-in cached siren14 format.
203 */
204extern struct ast_format *ast_format_siren14;
205
206/*!
207 * \brief Built-in cached siren7 format.
208 */
209extern struct ast_format *ast_format_siren7;
210
211/*!
212 * \brief Built-in cached opus format.
213 */
214extern struct ast_format *ast_format_opus;
215
216/*!
217 * \brief Built-in cached Codec 2 format.
218 */
219extern struct ast_format *ast_format_codec2;
220
221/*!
222 * \brief Built-in cached t140 format.
223 */
224extern struct ast_format *ast_format_t140;
225
226/*!
227 * \brief Built-in cached t140 red format.
228 */
229extern struct ast_format *ast_format_t140_red;
230
231/*!
232 * \brief Built-in cached T.38 format.
233 */
234extern struct ast_format *ast_format_t38;
235
236/*!
237 * \brief Built-in "null" format.
238 */
239extern struct ast_format *ast_format_none;
240
241/*!
242 * \brief Built-in SILK format.
243 */
244extern struct ast_format *ast_format_silk8;
245extern struct ast_format *ast_format_silk12;
246extern struct ast_format *ast_format_silk16;
247extern struct ast_format *ast_format_silk24;
248
249/*!
250 * \brief Initialize format cache support within the core.
251 *
252 * \retval 0 success
253 * \retval -1 failure
254 */
255int ast_format_cache_init(void);
256
257/*!
258 * \brief Set a named format cache entry.
259 *
260 * \param format A pointer to the format to cache
261 *
262 * \retval 0 success
263 * \retval -1 failure
264 */
265int ast_format_cache_set(struct ast_format *format);
266
267/*!
268 * \brief Retrieve a named format from the cache.
269 *
270 * \param name Name of the cached format
271 *
272 * \retval non-NULL if found
273 * \retval NULL if not found
274 *
275 * \note The returned format has its reference count incremented. It must be
276 * dropped using ao2_ref or ao2_cleanup.
277 */
278#define ast_format_cache_get(name) \
279 __ast_format_cache_get((name), "ast_format_cache_get", __FILE__, __LINE__, __PRETTY_FUNCTION__)
280#define ast_t_format_cache_get(name, tag) \
281 __ast_format_cache_get((name), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
282struct ast_format *__ast_format_cache_get(const char *name,
283 const char *tag, const char *file, int line, const char *func);
284
285/*!
286 * \brief Retrieve the best signed linear format given a sample rate.
287 *
288 * \param rate The sample rate
289 *
290 * \details
291 * This is a convenience function that returns one of the global
292 * ast_format_slinxxx formats.
293 *
294 * \return pointer to the signed linear format
295 *
296 * \note The returned format has NOT had its reference count incremented.
297 */
298struct ast_format *ast_format_cache_get_slin_by_rate(unsigned int rate);
299
300/*!
301 * \brief Determines if a format is one of the cached slin formats
302 *
303 * \param format The format to check
304 *
305 * \retval 0 if the format is not an SLIN format
306 * \retval 1 if the format is an SLIN format
307 */
308int ast_format_cache_is_slinear(struct ast_format *format);
309
310/*!
311 * \brief Retrieve a format from the cache by its codec
312 *
313 * \param codec The codec to search by
314 *
315 * \retval non-NULL if found
316 * \retval NULL if not found
317 *
318 * \note The returned format has its reference count incremented. It must be
319 * dropped using ao2_ref or ao2_cleanup.
320 */
322
323#endif /* _AST_FORMAT_CACHE_H */
struct ast_format * ast_format_speex16
Built-in cached speex at 16kHz format.
Definition: format_cache.c:136
struct ast_format * ast_format_h264
Built-in cached h264 format.
Definition: format_cache.c:176
struct ast_format * ast_format_slin44
Built-in cached signed linear 44kHz format.
Definition: format_cache.c:66
struct ast_format * ast_format_adpcm
Built-in cached adpcm format.
Definition: format_cache.c:101
struct ast_format * ast_format_slin24
Built-in cached signed linear 24kHz format.
Definition: format_cache.c:56
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:534
struct ast_format * ast_format_opus
Built-in cached opus format.
Definition: format_cache.c:221
int ast_format_cache_set(struct ast_format *format)
Set a named format cache entry.
Definition: format_cache.c:474
struct ast_format * ast_format_h265
Built-in cached h265 format.
Definition: format_cache.c:181
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:96
struct ast_format * ast_format_slin32
Built-in cached signed linear 32kHz format.
Definition: format_cache.c:61
struct ast_format * ast_format_siren14
Built-in cached siren14 format.
Definition: format_cache.c:211
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:131
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:166
struct ast_format * ast_format_mp4
Built-in cached mp4 format.
Definition: format_cache.c:186
struct ast_format * ast_format_slin192
Built-in cached signed linear 192kHz format.
Definition: format_cache.c:81
struct ast_format * ast_format_ilbc
Built-in cached ilbc format.
Definition: format_cache.c:121
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:111
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_lpc10
Built-in cached ilbc format.
Definition: format_cache.c:126
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:551
struct ast_format * ast_format_slin16
Built-in cached signed linear 16kHz format.
Definition: format_cache.c:51
struct ast_format * ast_format_codec2
Built-in cached Codec 2 format.
Definition: format_cache.c:226
struct ast_format * ast_format_slin96
Built-in cached signed linear 96kHz format.
Definition: format_cache.c:76
struct ast_format * ast_format_slin48
Built-in cached signed linear 48kHz format.
Definition: format_cache.c:71
int ast_format_cache_init(void)
Initialize format cache support within the core.
Definition: format_cache.c:364
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:146
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:246
struct ast_format * ast_format_siren7
Built-in cached siren7 format.
Definition: format_cache.c:216
struct ast_format * ast_format_silk12
Definition: format_cache.c:252
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_t38
Built-in cached T.38 format.
Definition: format_cache.c:241
struct ast_format * ast_format_speex32
Built-in cached speex at 32kHz format.
Definition: format_cache.c:141
struct ast_format * ast_format_h261
Built-in cached h261 format.
Definition: format_cache.c:161
struct ast_format * ast_format_vp9
Built-in cached vp9 format.
Definition: format_cache.c:196
struct ast_format * ast_format_t140_red
Built-in cached t140 red format.
Definition: format_cache.c:236
struct ast_format * ast_format_slin12
Built-in cached signed linear 12kHz format.
Definition: format_cache.c:46
struct ast_format * __ast_format_cache_get(const char *name, const char *tag, const char *file, int line, const char *func)
Definition: format_cache.c:502
struct ast_format * ast_format_h263p
Built-in cached h263 plus format.
Definition: format_cache.c:171
struct ast_format * ast_format_png
Built-in cached png format.
Definition: format_cache.c:206
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:512
struct ast_format * ast_format_g722
Built-in cached g722 format.
Definition: format_cache.c:106
struct ast_format * ast_format_silk16
Definition: format_cache.c:253
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:116
struct ast_format * ast_format_t140
Built-in cached t140 format.
Definition: format_cache.c:231
struct ast_format * ast_format_silk24
Definition: format_cache.c:254
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:151
struct ast_format * ast_format_jpeg
Built-in cached jpeg format.
Definition: format_cache.c:201
struct ast_format * ast_format_vp8
Built-in cached vp8 format.
Definition: format_cache.c:191
struct ast_format * ast_format_g719
Built-in cached g719 format.
Definition: format_cache.c:156
struct ast_format * ast_format_silk8
Built-in SILK format.
Definition: format_cache.c:251
static const char name[]
Definition: format_mp3.c:68
Represents a media codec within Asterisk.
Definition: codec.h:42
Definition of a media format.
Definition: format.c:43
struct ast_codec * codec
Pointer to the codec in use for this format.
Definition: format.c:47