silence_gen.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * silence_gen.c - A silence generator, for inserting timed silences.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2006 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 #if !defined(_SPANDSP_SILENCE_GEN_H_)
00027 #define _SPANDSP_SILENCE_GEN_H_
00028 
00029 typedef struct silence_gen_state_s silence_gen_state_t;
00030 
00031 #if defined(__cplusplus)
00032 extern "C"
00033 {
00034 #endif
00035 
00036 /*! Generate a block of silent audio samples.
00037     \brief Generate a block of silent audio samples.
00038     \param s The silence generator context.
00039     \param amp The audio sample buffer.
00040     \param max_len The number of samples to be generated.
00041     \return The number of samples actually generated. This will be zero when
00042             there is nothing to send.
00043 */
00044 SPAN_DECLARE_NONSTD(int) silence_gen(silence_gen_state_t *s, int16_t *amp, int max_len);
00045 
00046 /*! Set a silence generator context to output continuous silence.
00047     \brief Set a silence generator context to output continuous silence.
00048     \param s The silence generator context.
00049 */
00050 SPAN_DECLARE(void) silence_gen_always(silence_gen_state_t *s);
00051 
00052 /*! Set a silence generator context to output a specified period of silence.
00053     \brief Set a silence generator context to output a specified period of silence.
00054     \param s The silence generator context.
00055     \param silent_samples The number of samples to be generated.
00056 */
00057 SPAN_DECLARE(void) silence_gen_set(silence_gen_state_t *s, int silent_samples);
00058 
00059 /*! Alter the period of a silence generator context by a specified amount.
00060     \brief Alter the period of a silence generator context by a specified amount.
00061     \param s The silence generator context.
00062     \param silent_samples The number of samples to change the setting by. A positive number
00063                           increases the duration. A negative number reduces it. The duration
00064                           is prevented from going negative.
00065 */
00066 SPAN_DECLARE(void) silence_gen_alter(silence_gen_state_t *s, int silent_samples);
00067 
00068 /*! Find how long a silence generator context has to run.
00069     \brief Find how long a silence generator context has to run.
00070     \param s The silence generator context.
00071     \return The number of samples remaining.
00072 */
00073 SPAN_DECLARE(int) silence_gen_remainder(silence_gen_state_t *s);
00074 
00075 /*! Find the total silence generated to date by a silence generator context.
00076     \brief Find the total silence generated to date.
00077     \param s The silence generator context.
00078     \return The number of samples generated.
00079 */
00080 SPAN_DECLARE(int) silence_gen_generated(silence_gen_state_t *s);
00081 
00082 /*! Change the status reporting function associated with a silence generator context.
00083     \brief Change the status reporting function associated with a silence generator context.
00084     \param s The silence generator context.
00085     \param handler The callback routine used to report status changes.
00086     \param user_data An opaque pointer. */
00087 SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_tx_status_func_t handler, void *user_data);
00088 
00089 /*! Initialise a timed silence generator context.
00090     \brief Initialise a timed silence generator context.
00091     \param s The silence generator context.
00092     \param silent_samples The initial number of samples to set the silence to.
00093     \return A pointer to the silence generator context.
00094 */
00095 SPAN_DECLARE(silence_gen_state_t *) silence_gen_init(silence_gen_state_t *s, int silent_samples);
00096 
00097 SPAN_DECLARE(int) silence_gen_release(silence_gen_state_t *s);
00098 
00099 SPAN_DECLARE(int) silence_gen_free(silence_gen_state_t *s);
00100 
00101 /* The following dummy routines, to absorb data, don't really have a proper home,
00102    so they have been put here. */
00103 
00104 /*! A dummy routine to use as a receive callback, when we aren't really
00105     trying to process what is received. It just absorbs and ignores the
00106     data.
00107     \brief Dummy receive callback.
00108     \param user_data The context.
00109     \param amp The signal.buffer
00110     \param len The length of the signal buffer
00111     \return 0.
00112 */
00113 SPAN_DECLARE_NONSTD(int) span_dummy_rx(void *user_data, const int16_t amp[], int len);
00114 
00115 /*! A dummy routine to use as a signal modifier callback, when we aren't
00116     really trying to process the signal. It just returns without affecting
00117     anything.
00118     \brief Dummy signal modifier callback.
00119     \param user_data The context.
00120     \param amp The signal.buffer
00121     \param len The length of the signal buffer
00122     \return 0.
00123 */
00124 SPAN_DECLARE(int) span_dummy_mod(void *user_data, int16_t amp[], int len);
00125 
00126 /*! A dummy routine to use as a receive fillin callback, when we aren't really
00127     trying to process what is received. It just absorbs and ignores the
00128     request.
00129     \brief Dummy receive fillin callback.
00130     \param user_data The context.
00131     \param len The length of the signal buffer
00132     \return 0.
00133 */
00134 SPAN_DECLARE_NONSTD(int) span_dummy_rx_fillin(void *user_data, int len);
00135 
00136 #if defined(__cplusplus)
00137 }
00138 #endif
00139 
00140 #endif
00141 /*- End of file ------------------------------------------------------------*/

Generated on Thu Oct 18 15:28:01 2012 for spandsp by  doxygen 1.4.7