format_cache.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2014, Digium, Inc.
00005  *
00006  * Joshua Colp <jcolp@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020  * \file
00021  * \brief Media Format Cache API
00022  *
00023  * \author Joshua Colp <jcolp@digium.com>
00024  */
00025 
00026 #ifndef _AST_FORMAT_CACHE_H_
00027 #define _AST_FORMAT_CACHE_H_
00028 
00029 struct ast_format;
00030 
00031 /*!
00032  * \brief Built-in cached signed linear 8kHz format.
00033  */
00034 extern struct ast_format *ast_format_slin;
00035 
00036 /*!
00037  * \brief Built-in cached signed linear 12kHz format.
00038  */
00039 extern struct ast_format *ast_format_slin12;
00040 
00041 /*!
00042  * \brief Built-in cached signed linear 16kHz format.
00043  */
00044 extern struct ast_format *ast_format_slin16;
00045 
00046 /*!
00047  * \brief Built-in cached signed linear 24kHz format.
00048  */
00049 extern struct ast_format *ast_format_slin24;
00050 
00051 /*!
00052  * \brief Built-in cached signed linear 32kHz format.
00053  */
00054 extern struct ast_format *ast_format_slin32;
00055 
00056 /*!
00057  * \brief Built-in cached signed linear 44kHz format.
00058  */
00059 extern struct ast_format *ast_format_slin44;
00060 
00061 /*!
00062  * \brief Built-in cached signed linear 48kHz format.
00063  */
00064 extern struct ast_format *ast_format_slin48;
00065 
00066 /*!
00067  * \brief Built-in cached signed linear 96kHz format.
00068  */
00069 extern struct ast_format *ast_format_slin96;
00070 
00071 /*!
00072  * \brief Built-in cached signed linear 192kHz format.
00073  */
00074 extern struct ast_format *ast_format_slin192;
00075 
00076 /*!
00077  * \brief Built-in cached ulaw format.
00078  */
00079 extern struct ast_format *ast_format_ulaw;
00080 
00081 /*!
00082  * \brief Built-in cached alaw format.
00083  */
00084 extern struct ast_format *ast_format_alaw;
00085 
00086 /*!
00087  * \brief Built-in cached testlaw format.
00088  */
00089 extern struct ast_format *ast_format_testlaw;
00090 
00091 /*!
00092  * \brief Built-in cached gsm format.
00093  */
00094 extern struct ast_format *ast_format_gsm;
00095 
00096 /*!
00097  * \brief Built-in cached adpcm format.
00098  */
00099 extern struct ast_format *ast_format_adpcm;
00100 
00101 /*!
00102  * \brief Built-in cached g722 format.
00103  */
00104 extern struct ast_format *ast_format_g722;
00105 
00106 /*!
00107  * \brief Built-in cached g726 format.
00108  */
00109 extern struct ast_format *ast_format_g726;
00110 
00111 /*!
00112  * \brief Built-in cached g726 aal2 format.
00113  */
00114 extern struct ast_format *ast_format_g726_aal2;
00115 
00116 /*!
00117  * \brief Built-in cached ilbc format.
00118  */
00119 extern struct ast_format *ast_format_ilbc;
00120 
00121 /*!
00122  * \brief Built-in cached ilbc format.
00123  */
00124 extern struct ast_format *ast_format_lpc10;
00125 
00126 /*!
00127  * \brief Built-in cached speex format.
00128  */
00129 extern struct ast_format *ast_format_speex;
00130 
00131 /*!
00132  * \brief Built-in cached speex at 16kHz format.
00133  */
00134 extern struct ast_format *ast_format_speex16;
00135 
00136 /*!
00137  * \brief Built-in cached speex at 32kHz format.
00138  */
00139 extern struct ast_format *ast_format_speex32;
00140 
00141 /*!
00142  * \brief Built-in cached g723.1 format.
00143  */
00144 extern struct ast_format *ast_format_g723;
00145 
00146 /*!
00147  * \brief Built-in cached g729 format.
00148  */
00149 extern struct ast_format *ast_format_g729;
00150 
00151 /*!
00152  * \brief Built-in cached g719 format.
00153  */
00154 extern struct ast_format *ast_format_g719;
00155 
00156 /*!
00157  * \brief Built-in cached h261 format.
00158  */
00159 extern struct ast_format *ast_format_h261;
00160 
00161 /*!
00162  * \brief Built-in cached h263 format.
00163  */
00164 extern struct ast_format *ast_format_h263;
00165 
00166 /*!
00167  * \brief Built-in cached h263 plus format.
00168  */
00169 extern struct ast_format *ast_format_h263p;
00170 
00171 /*!
00172  * \brief Built-in cached h264 format.
00173  */
00174 extern struct ast_format *ast_format_h264;
00175 
00176 /*!
00177  * \brief Built-in cached mp4 format.
00178  */
00179 extern struct ast_format *ast_format_mp4;
00180 
00181 /*!
00182  * \brief Built-in cached vp8 format.
00183  */
00184 extern struct ast_format *ast_format_vp8;
00185 
00186 /*!
00187  * \brief Built-in cached jpeg format.
00188  */
00189 extern struct ast_format *ast_format_jpeg;
00190 
00191 /*!
00192  * \brief Built-in cached png format.
00193  */
00194 extern struct ast_format *ast_format_png;
00195 
00196 /*!
00197  * \brief Built-in cached siren14 format.
00198  */
00199 extern struct ast_format *ast_format_siren14;
00200 
00201 /*!
00202  * \brief Built-in cached siren7 format.
00203  */
00204 extern struct ast_format *ast_format_siren7;
00205 
00206 /*!
00207  * \brief Built-in cached opus format.
00208  */
00209 extern struct ast_format *ast_format_opus;
00210 
00211 /*!
00212  * \brief Built-in cached t140 format.
00213  */
00214 extern struct ast_format *ast_format_t140;
00215 
00216 /*!
00217  * \brief Built-in cached t140 red format.
00218  */
00219 extern struct ast_format *ast_format_t140_red;
00220 
00221 /*!
00222  * \brief Built-in "null" format.
00223  */
00224 extern struct ast_format *ast_format_none;
00225 
00226 /*!
00227  * \brief Initialize format cache support within the core.
00228  *
00229  * \retval 0 success
00230  * \retval -1 failure
00231  */
00232 int ast_format_cache_init(void);
00233 
00234 /*!
00235  * \brief Set a named format cache entry.
00236  *
00237  * \param format A pointer to the format to cache
00238  *
00239  * \retval 0 success
00240  * \retval -1 failure
00241  */
00242 int ast_format_cache_set(struct ast_format *format);
00243 
00244 /*!
00245  * \brief Retrieve a named format from the cache.
00246  *
00247  * \param name Name of the cached format
00248  *
00249  * \retval non-NULL if found
00250  * \retval NULL if not found
00251  *
00252  * \note The returned format has its reference count incremented. It must be
00253  * dropped using ao2_ref or ao2_cleanup.
00254  */
00255 struct ast_format *__ast_format_cache_get(const char *name);
00256 struct ast_format *__ast_format_cache_get_debug(const char *name, const char *tag, const char *file, int line, const char *func);
00257 
00258 #ifdef REF_DEBUG
00259 #define ast_format_cache_get(name) \
00260    __ast_format_cache_get_debug((name), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
00261 #define ast_t_format_cache_get(name, tag) \
00262    __ast_format_cache_get_debug((name), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
00263 #else
00264 #define ast_format_cache_get(name) \
00265    __ast_format_cache_get((name))
00266 #define ast_t_format_cache_get(name, tag) \
00267    __ast_format_cache_get((name))
00268 #endif
00269 
00270 
00271 /*!
00272  * \brief Retrieve the best signed linear format given a sample rate.
00273  *
00274  * \param rate The sample rate
00275  *
00276  * \details
00277  * This is a convenience function that returns one of the global
00278  * ast_format_slinxxx formats.
00279  *
00280  * \return pointer to the signed linear format
00281  *
00282  * \note The returned format has NOT had its reference count incremented.
00283  */
00284 struct ast_format *ast_format_cache_get_slin_by_rate(unsigned int rate);
00285 
00286 /*!
00287  * \brief Determines if a format is one of the cached slin formats
00288  *
00289  * \param format The format to check
00290  *
00291  * \retval 0 if the format is not an SLIN format
00292  * \retval 1 if the format is an SLIN format
00293  */
00294 int ast_format_cache_is_slinear(struct ast_format *format);
00295 
00296 #endif /* _AST_FORMAT_CACHE_H */

Generated on Thu Apr 16 06:27:34 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6