/usr/include/pjmedia/tonegen.h is in libpjproject-dev 2.1.0.0.ast20130823-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | /* $Id: tonegen.h 3553 2011-05-05 06:14:19Z nanang $ */
/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJMEDIA_TONEGEN_PORT_H__
#define __PJMEDIA_TONEGEN_PORT_H__
/**
* @file tonegen.h
* @brief Tone (sine, MF, DTMF) generator media port.
*/
#include <pjmedia/port.h>
/**
* @defgroup PJMEDIA_MF_DTMF_TONE_GENERATOR Multi-frequency tone generator
* @ingroup PJMEDIA_PORT
* @brief Multi-frequency tone generator
* @{
*
* This page describes tone generator media port. A tone generator can be
* used to generate a single frequency sine wave or dual frequency tones
* such as DTMF.
*
* The tone generator media port provides two functions to generate tones.
* The function #pjmedia_tonegen_play() can be used to generate arbitrary
* single or dual frequency tone, and #pjmedia_tonegen_play_digits() is
* used to play digits such as DTMF. Each tone specified in the playback
* function has individual on and off signal duration that must be
* specified by application.
*
* In order to play digits such as DTMF, the tone generator is equipped
* with digit map, which contain information about the frequencies of
* the digits. The default digit map is DTMF (0-9,a-d,*,#), but application
* may specifiy different digit map to the tone generator by calling
* #pjmedia_tonegen_set_digit_map() function.
*/
PJ_BEGIN_DECL
/**
* This structure describes individual MF digits to be played
* with #pjmedia_tonegen_play().
*/
typedef struct pjmedia_tone_desc
{
short freq1; /**< First frequency. */
short freq2; /**< Optional second frequency. */
short on_msec; /**< Playback ON duration, in miliseconds. */
short off_msec; /**< Playback OFF duration, ini miliseconds. */
short volume; /**< Volume (1-32767), or 0 for default, which
PJMEDIA_TONEGEN_VOLUME will be used. */
short flags; /**< Currently internal flags, must be 0 */
} pjmedia_tone_desc;
/**
* This structure describes individual MF digits to be played
* with #pjmedia_tonegen_play_digits().
*/
typedef struct pjmedia_tone_digit
{
char digit; /**< The ASCI identification for the digit. */
short on_msec; /**< Playback ON duration, in miliseconds. */
short off_msec; /**< Playback OFF duration, ini miliseconds. */
short volume; /**< Volume (1-32767), or 0 for default, which
PJMEDIA_TONEGEN_VOLUME will be used. */
} pjmedia_tone_digit;
/**
* This structure describes the digit map which is used by the tone generator
* to produce tones from an ASCII digits.
* Digit map used by a particular tone generator can be retrieved/set with
* #pjmedia_tonegen_get_digit_map() and #pjmedia_tonegen_set_digit_map().
*/
typedef struct pjmedia_tone_digit_map
{
unsigned count; /**< Number of digits in the map. */
struct {
char digit; /**< The ASCI identification for the digit. */
short freq1; /**< First frequency. */
short freq2; /**< Optional second frequency. */
} digits[16]; /**< Array of digits in the digit map. */
} pjmedia_tone_digit_map;
/**
* Tone generator options.
*/
enum
{
/**
* Play the tones in loop, restarting playing the first tone after
* the last tone has been played.
*/
PJMEDIA_TONEGEN_LOOP = 1,
/**
* Disable mutex protection to the tone generator.
*/
PJMEDIA_TONEGEN_NO_LOCK = 2
};
/**
* Create an instance of tone generator with the specified parameters.
* When the tone generator is first created, it will be loaded with the
* default digit map.
*
* @param pool Pool to allocate memory for the port structure.
* @param clock_rate Sampling rate.
* @param channel_count Number of channels. Currently only mono and stereo
* are supported.
* @param samples_per_frame Number of samples per frame.
* @param bits_per_sample Number of bits per sample. This version of PJMEDIA
* only supports 16bit per sample.
* @param options Option flags. Application may specify
* PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
* @param p_port Pointer to receive the port instance.
*
* @return PJ_SUCCESS on success, or the appropriate
* error code.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_create(pj_pool_t *pool,
unsigned clock_rate,
unsigned channel_count,
unsigned samples_per_frame,
unsigned bits_per_sample,
unsigned options,
pjmedia_port **p_port);
/**
* Create an instance of tone generator with the specified parameters.
* When the tone generator is first created, it will be loaded with the
* default digit map.
*
* @param pool Pool to allocate memory for the port structure.
* @param name Optional name for the tone generator.
* @param clock_rate Sampling rate.
* @param channel_count Number of channels. Currently only mono and stereo
* are supported.
* @param samples_per_frame Number of samples per frame.
* @param bits_per_sample Number of bits per sample. This version of PJMEDIA
* only supports 16bit per sample.
* @param options Option flags. Application may specify
* PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
* @param p_port Pointer to receive the port instance.
*
* @return PJ_SUCCESS on success, or the appropriate
* error code.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_create2(pj_pool_t *pool,
const pj_str_t *name,
unsigned clock_rate,
unsigned channel_count,
unsigned samples_per_frame,
unsigned bits_per_sample,
unsigned options,
pjmedia_port **p_port);
/**
* Check if the tone generator is still busy producing some tones.
*
* @param tonegen The tone generator instance.
*
* @return Non-zero if busy.
*/
PJ_DECL(pj_bool_t) pjmedia_tonegen_is_busy(pjmedia_port *tonegen);
/**
* Instruct the tone generator to stop current processing.
*
* @param tonegen The tone generator instance.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_stop(pjmedia_port *tonegen);
/**
* Rewind the playback. This will start the playback to the first
* tone in the playback list.
*
* @param tonegen The tone generator instance.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_rewind(pjmedia_port *tonegen);
/**
* Instruct the tone generator to play single or dual frequency tones
* with the specified duration. The new tones will be appended to currently
* playing tones, unless #pjmedia_tonegen_stop() is called before calling
* this function. The playback will begin as soon as the first get_frame()
* is called to the generator.
*
* @param tonegen The tone generator instance.
* @param count The number of tones in the array.
* @param tones Array of tones to be played.
* @param options Option flags. Application may specify
* PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
*
* @return PJ_SUCCESS on success, or PJ_ETOOMANY if
* there are too many digits in the queue.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_play(pjmedia_port *tonegen,
unsigned count,
const pjmedia_tone_desc tones[],
unsigned options);
/**
* Instruct the tone generator to play multiple MF digits with each of
* the digits having individual ON/OFF duration. Each of the digit in the
* digit array must have the corresponding descriptor in the digit map.
* The new tones will be appended to currently playing tones, unless
* #pjmedia_tonegen_stop() is called before calling this function.
* The playback will begin as soon as the first get_frame() is called
* to the generator.
*
* @param tonegen The tone generator instance.
* @param count Number of digits in the array.
* @param digits Array of MF digits.
* @param options Option flags. Application may specify
* PJMEDIA_TONEGEN_LOOP to play the tone in a loop.
*
* @return PJ_SUCCESS on success, or PJ_ETOOMANY if
* there are too many digits in the queue, or
* PJMEDIA_RTP_EINDTMF if invalid digit is
* specified.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_play_digits(pjmedia_port *tonegen,
unsigned count,
const pjmedia_tone_digit digits[],
unsigned options);
/**
* Get the digit-map currently used by this tone generator.
*
* @param tonegen The tone generator instance.
* @param m On output, it will be filled with the pointer to
* the digitmap currently used by the tone generator.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_get_digit_map(pjmedia_port *tonegen,
const pjmedia_tone_digit_map **m);
/**
* Set digit map to be used by the tone generator.
*
* @param tonegen The tone generator instance.
* @param m Digitmap to be used by the tone generator.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_tonegen_set_digit_map(pjmedia_port *tonegen,
pjmedia_tone_digit_map *m);
PJ_END_DECL
/**
* @}
*/
#endif /* __PJMEDIA_TONEGEN_PORT_H__ */
|