Wed Jan 27 20:02:16 2016

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    format_t format;                         /*!< Current format the translation path is converting from */
00041    format_t output_format;                  /*!< The output format desired */
00042 };
00043 
00044 /*!
00045  * \brief Initialize a slinfactory
00046  *
00047  * \param sf The slinfactory to initialize
00048  *
00049  * \return Nothing
00050  */
00051 void ast_slinfactory_init(struct ast_slinfactory *sf);
00052 
00053 /*!
00054  * \brief Initialize a slinfactory
00055  *
00056  * \param sf The slinfactory to initialize
00057  * \param sample_rate The output sample rate desired
00058  *
00059  * \return 0 on success, non-zero on failure
00060  */
00061 int ast_slinfactory_init_rate(struct ast_slinfactory *sf, unsigned int sample_rate);
00062 
00063 /*!
00064  * \brief Destroy the contents of a slinfactory
00065  *
00066  * \param sf The slinfactory that is no longer needed
00067  *
00068  * This function will free any memory allocated for the contents of the
00069  * slinfactory.  It does not free the slinfactory itself.  If the sf is
00070  * malloc'd, then it must be explicitly free'd after calling this function.
00071  *
00072  * \return Nothing
00073  */
00074 void ast_slinfactory_destroy(struct ast_slinfactory *sf);
00075 
00076 /*!
00077  * \brief Feed audio into a slinfactory
00078  *
00079  * \param sf The slinfactory to feed into
00080  * \param f Frame containing audio to feed in
00081  *
00082  * \return Number of frames currently in factory
00083  */
00084 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
00085 
00086 /*!
00087  * \brief Read samples from a slinfactory
00088  *
00089  * \param sf The slinfactory to read from
00090  * \param buf Buffer to put samples into
00091  * \param samples Number of samples wanted
00092  *
00093  * \return Number of samples read
00094  */
00095 int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
00096 
00097 /*!
00098  * \brief Retrieve number of samples currently in a slinfactory
00099  *
00100  * \param sf The slinfactory to peek into
00101  *
00102  * \return Number of samples in slinfactory
00103  */
00104 unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
00105 
00106 /*!
00107  * \brief Flush the contents of a slinfactory
00108  *
00109  * \param sf The slinfactory to flush
00110  *
00111  * \return Nothing
00112  */
00113 void ast_slinfactory_flush(struct ast_slinfactory *sf);
00114 
00115 #if defined(__cplusplus) || defined(c_plusplus)
00116 }
00117 #endif
00118 
00119 #endif /* _ASTERISK_SLINFACTORY_H */

Generated on 27 Jan 2016 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1