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 #include <stdlib.h> 00027 #include <unistd.h> 00028 #include <string.h> 00029 00030 #if defined(__cplusplus) || defined(c_plusplus) 00031 extern "C" { 00032 #endif 00033 00034 #define AST_SLINFACTORY_MAX_HOLD 1280 00035 00036 struct ast_slinfactory { 00037 AST_LIST_HEAD_NOLOCK(, ast_frame) queue; 00038 struct ast_trans_pvt *trans; 00039 short hold[AST_SLINFACTORY_MAX_HOLD]; 00040 short *offset; 00041 size_t holdlen; /*!< in samples */ 00042 unsigned int size; /*!< in samples */ 00043 unsigned int format; 00044 }; 00045 00046 void ast_slinfactory_init(struct ast_slinfactory *sf); 00047 void ast_slinfactory_destroy(struct ast_slinfactory *sf); 00048 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f); 00049 int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples); 00050 unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf); 00051 void ast_slinfactory_flush(struct ast_slinfactory *sf); 00052 00053 #if defined(__cplusplus) || defined(c_plusplus) 00054 } 00055 #endif 00056 00057 #endif /* _ASTERISK_SLINFACTORY_H */