00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 2005, Anthony Minessale II 00005 * 00006 * Anthony Minessale <anthmct@yahoo.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 /*! \file 00020 * \brief A machine to gather up arbitrary frames and convert them 00021 * to raw slinear on demand. 00022 */ 00023 00024 #ifndef _ASTERISK_SLINFACTORY_H 00025 #define _ASTERISK_SLINFACTORY_H 00026 00027 #if defined(__cplusplus) || defined(c_plusplus) 00028 extern "C" { 00029 #endif 00030 00031 #define AST_SLINFACTORY_MAX_HOLD 1280 00032 00033 struct ast_slinfactory { 00034 AST_LIST_HEAD_NOLOCK(, ast_frame) queue; 00035 struct ast_trans_pvt *trans; 00036 short hold[AST_SLINFACTORY_MAX_HOLD]; 00037 short *offset; 00038 size_t holdlen; /*!< in samples */ 00039 unsigned int size; /*!< in samples */ 00040 unsigned int format; 00041 }; 00042 00043 void ast_slinfactory_init(struct ast_slinfactory *sf); 00044 00045 /*! 00046 * \brief Destroy the contents of a slinfactory 00047 * 00048 * \arg sf the slinfactory that is no longer needed 00049 * 00050 * This function will free any memory allocated for the contents of the 00051 * slinfactory. It does not free the slinfactory itself. If the sf is 00052 * malloc'd, then it must be explicitly free'd after calling this function. 00053 * 00054 * \return nothing 00055 */ 00056 void ast_slinfactory_destroy(struct ast_slinfactory *sf); 00057 00058 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f); 00059 int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples); 00060 unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf); 00061 void ast_slinfactory_flush(struct ast_slinfactory *sf); 00062 00063 #if defined(__cplusplus) || defined(c_plusplus) 00064 } 00065 #endif 00066 00067 #endif /* _ASTERISK_SLINFACTORY_H */