Fri Jul 24 00:41:05 2009

Asterisk developer's documentation


slinfactory.h

Go to the documentation of this file.
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; /*!< A list of unaltered frames */
00035    struct ast_trans_pvt *trans;             /*!< Translation path that converts fed frames into signed linear */
00036    short hold[AST_SLINFACTORY_MAX_HOLD];    /*!< Hold for audio that no longer belongs to a frame (ie: if only some samples were taken from a frame) */
00037    short *offset;                           /*!< Offset into the hold where audio begins */
00038    size_t holdlen;                          /*!< Number of samples currently in the hold */
00039    unsigned int size;                       /*!< Number of samples currently in the factory */
00040    unsigned int format;                     /*!< Current format the translation path is converting from */
00041 };
00042 
00043 /*!
00044  * \brief Initialize an slinfactory
00045  *
00046  * \param sf The slinfactory to initialize
00047  *
00048  * \return Nothing
00049  */
00050 void ast_slinfactory_init(struct ast_slinfactory *sf);
00051 
00052 /*!
00053  * \brief Destroy the contents of a slinfactory
00054  *
00055  * \param sf The slinfactory that is no longer needed
00056  *
00057  * This function will free any memory allocated for the contents of the
00058  * slinfactory.  It does not free the slinfactory itself.  If the sf is
00059  * malloc'd, then it must be explicitly free'd after calling this function.
00060  *
00061  * \return Nothing
00062  */
00063 void ast_slinfactory_destroy(struct ast_slinfactory *sf);
00064 
00065 /*!
00066  * \brief Feed audio into an slinfactory
00067  *
00068  * \param sf The slinfactory to feed into
00069  * \param f Frame containing audio to feed in
00070  *
00071  * \return Number of frames currently in factory
00072  */
00073 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
00074 
00075 /*!
00076  * \brief Read samples from an slinfactory
00077  *
00078  * \param sf The slinfactory to read from
00079  * \param buf Buffer to put samples into
00080  * \param samples Number of samples wanted
00081  *
00082  * \return Number of samples read
00083  */
00084 int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
00085 
00086 /*!
00087  * \brief Retrieve number of samples currently in an slinfactory
00088  *
00089  * \param sf The slinfactory to peek into
00090  *
00091  * \return Number of samples in slinfactory
00092  */
00093 unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
00094 
00095 /*!
00096  * \brief Flush the contents of an slinfactory
00097  *
00098  * \param sf The slinfactory to flush
00099  *
00100  * \return Nothing
00101  */
00102 void ast_slinfactory_flush(struct ast_slinfactory *sf);
00103 
00104 #if defined(__cplusplus) || defined(c_plusplus)
00105 }
00106 #endif
00107 
00108 #endif /* _ASTERISK_SLINFACTORY_H */

Generated on Fri Jul 24 00:41:05 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7