2005-07-20 00:53:21 +00:00
|
|
|
/*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2005-07-20 00:53:21 +00:00
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Copyright (C) 2005, Anthony Minessale II
|
2005-07-20 00:53:21 +00:00
|
|
|
*
|
|
|
|
|
* Anthony Minessale <anthmct@yahoo.com>
|
|
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
|
* channels for your use.
|
|
|
|
|
*
|
2005-07-20 00:53:21 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-08-30 18:32:10 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
|
* at the top of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
|
|
|
|
* \brief A machine to gather up arbitrary frames and convert them
|
2005-08-30 18:32:10 +00:00
|
|
|
* to raw slinear on demand.
|
2005-07-20 00:53:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _ASTERISK_SLINFACTORY_H
|
|
|
|
|
#define _ASTERISK_SLINFACTORY_H
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-04-07 14:54:42 +00:00
|
|
|
#define AST_SLINFACTORY_MAX_HOLD 1280
|
|
|
|
|
|
2006-07-28 18:59:59 +00:00
|
|
|
struct ast_slinfactory {
|
2008-03-12 21:06:50 +00:00
|
|
|
AST_LIST_HEAD_NOLOCK(, ast_frame) queue; /*!< A list of unaltered frames */
|
|
|
|
|
struct ast_trans_pvt *trans; /*!< Translation path that converts fed frames into signed linear */
|
2008-04-07 14:54:42 +00:00
|
|
|
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) */
|
2008-03-12 21:06:50 +00:00
|
|
|
short *offset; /*!< Offset into the hold where audio begins */
|
|
|
|
|
size_t holdlen; /*!< Number of samples currently in the hold */
|
|
|
|
|
unsigned int size; /*!< Number of samples currently in the factory */
|
|
|
|
|
unsigned int format; /*!< Current format the translation path is converting from */
|
2006-07-28 18:59:59 +00:00
|
|
|
};
|
2005-07-20 00:53:21 +00:00
|
|
|
|
2008-03-12 21:06:50 +00:00
|
|
|
/*!
|
|
|
|
|
* \brief Initialize an slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory to initialize
|
2008-03-12 21:06:50 +00:00
|
|
|
*
|
|
|
|
|
* \return Nothing
|
|
|
|
|
*/
|
2005-07-20 00:53:21 +00:00
|
|
|
void ast_slinfactory_init(struct ast_slinfactory *sf);
|
2007-09-08 19:01:20 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Destroy the contents of a slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory that is no longer needed
|
2007-09-08 19:01:20 +00:00
|
|
|
*
|
|
|
|
|
* This function will free any memory allocated for the contents of the
|
|
|
|
|
* slinfactory. It does not free the slinfactory itself. If the sf is
|
|
|
|
|
* malloc'd, then it must be explicitly free'd after calling this function.
|
|
|
|
|
*
|
2008-03-12 21:06:50 +00:00
|
|
|
* \return Nothing
|
2007-09-08 19:01:20 +00:00
|
|
|
*/
|
2005-07-20 00:53:21 +00:00
|
|
|
void ast_slinfactory_destroy(struct ast_slinfactory *sf);
|
2007-09-08 19:01:20 +00:00
|
|
|
|
2008-03-12 21:06:50 +00:00
|
|
|
/*!
|
|
|
|
|
* \brief Feed audio into an slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory to feed into
|
|
|
|
|
* \param f Frame containing audio to feed in
|
2008-03-12 21:06:50 +00:00
|
|
|
*
|
|
|
|
|
* \return Number of frames currently in factory
|
|
|
|
|
*/
|
2005-07-20 00:53:21 +00:00
|
|
|
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
|
2008-03-12 21:06:50 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Read samples from an slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory to read from
|
|
|
|
|
* \param buf Buffer to put samples into
|
|
|
|
|
* \param samples Number of samples wanted
|
2008-03-12 21:06:50 +00:00
|
|
|
*
|
|
|
|
|
* \return Number of samples read
|
|
|
|
|
*/
|
2006-07-28 18:03:57 +00:00
|
|
|
int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
|
2008-03-12 21:06:50 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Retrieve number of samples currently in an slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory to peek into
|
2008-03-12 21:06:50 +00:00
|
|
|
*
|
|
|
|
|
* \return Number of samples in slinfactory
|
|
|
|
|
*/
|
2006-07-28 18:03:57 +00:00
|
|
|
unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
|
2008-03-12 21:06:50 +00:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Flush the contents of an slinfactory
|
|
|
|
|
*
|
2008-07-02 14:50:45 +00:00
|
|
|
* \param sf The slinfactory to flush
|
2008-03-12 21:06:50 +00:00
|
|
|
*
|
|
|
|
|
* \return Nothing
|
|
|
|
|
*/
|
2007-08-08 19:30:52 +00:00
|
|
|
void ast_slinfactory_flush(struct ast_slinfactory *sf);
|
2005-07-20 00:53:21 +00:00
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-08-30 18:32:10 +00:00
|
|
|
#endif /* _ASTERISK_SLINFACTORY_H */
|