/usr/include/pjmedia/delaybuf.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 | /* $Id: delaybuf.h 3841 2011-10-24 09:28:13Z ming $ */
/*
* 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_DELAYBUF_H__
#define __PJMEDIA_DELAYBUF_H__
/**
* @file delaybuf.h
* @brief Delay Buffer.
*/
#include <pjmedia/types.h>
/**
* @defgroup PJMED_DELAYBUF Adaptive Delay Buffer
* @ingroup PJMEDIA_FRAME_OP
* @brief Adaptive delay buffer with high-quality time-scale
* modification
* @{
*
* This section describes PJMEDIA's implementation of delay buffer.
* Delay buffer works quite similarly like a fixed jitter buffer, that
* is it will delay the frame retrieval by some interval so that caller
* will get continuous frame from the buffer. This can be useful when
* the put() and get() operations are not evenly interleaved, for example
* when caller performs burst of put() operations and then followed by
* burst of get() operations. With using this delay buffer, the buffer
* will put the burst frames into a buffer so that get() operations
* will always get a frame from the buffer (assuming that the number of
* get() and put() are matched).
*
* The buffer is adaptive, that is it continuously learns the optimal delay
* to be applied to the audio flow at run-time. Once the optimal delay has
* been learned, the delay buffer will apply this delay to the audio flow,
* expanding or shrinking the audio samples as necessary when the actual
* audio samples in the buffer are too low or too high. It does this without
* distorting the audio quality of the audio, by using \a PJMED_WSOLA.
*
* The delay buffer is used in \ref PJMED_SND_PORT, \ref PJMEDIA_SPLITCOMB,
* and \ref PJMEDIA_CONF.
*/
PJ_BEGIN_DECL
/** Opaque declaration for delay buffer. */
typedef struct pjmedia_delay_buf pjmedia_delay_buf;
/**
* Delay buffer options.
*/
typedef enum pjmedia_delay_buf_flag
{
/**
* Use simple FIFO mechanism for the delay buffer, i.e.
* without WSOLA for expanding and shrinking audio samples.
*/
PJMEDIA_DELAY_BUF_SIMPLE_FIFO = 1
} pjmedia_delay_buf_flag;
/**
* Create the delay buffer. Once the delay buffer is created, it will
* enter learning state unless the delay argument is specified, which
* in this case it will directly enter the running state.
*
* @param pool Pool where the delay buffer will be allocated
* from.
* @param name Optional name for the buffer for log
* identification.
* @param clock_rate Number of samples processed per second.
* @param samples_per_frame Number of samples per frame.
* @param channel_count Number of channel per frame.
* @param max_delay Maximum number of delay to be accommodated,
* in ms, if this value is negative or less than
* one frame time, default maximum delay used is
* 400 ms.
* @param options Options. If PJMEDIA_DELAY_BUF_SIMPLE_FIFO is
* specified, then a simple FIFO mechanism
* will be used instead of the adaptive
* implementation (which uses WSOLA to expand
* or shrink audio samples).
* See #pjmedia_delay_buf_flag for other options.
* @param p_b Pointer to receive the delay buffer instance.
*
* @return PJ_SUCCESS if the delay buffer has been
* created successfully, otherwise the appropriate
* error will be returned.
*/
PJ_DECL(pj_status_t) pjmedia_delay_buf_create(pj_pool_t *pool,
const char *name,
unsigned clock_rate,
unsigned samples_per_frame,
unsigned channel_count,
unsigned max_delay,
unsigned options,
pjmedia_delay_buf **p_b);
/**
* Put one frame into the buffer.
*
* @param b The delay buffer.
* @param frame Frame to be put into the buffer. This frame
* must have samples_per_frame length.
*
* @return PJ_SUCCESS if frames can be put successfully.
* PJ_EPENDING if the buffer is still at learning
* state. PJ_ETOOMANY if the number of frames
* will exceed maximum delay level, which in this
* case the new frame will overwrite the oldest
* frame in the buffer.
*/
PJ_DECL(pj_status_t) pjmedia_delay_buf_put(pjmedia_delay_buf *b,
pj_int16_t frame[]);
/**
* Get one frame from the buffer.
*
* @param b The delay buffer.
* @param frame Buffer to receive the frame from the delay
* buffer.
*
* @return PJ_SUCCESS if frame has been copied successfully.
* PJ_EPENDING if no frame is available, either
* because the buffer is still at learning state or
* no buffer is available during running state.
* On non-successful return, the frame will be
* filled with zeroes.
*/
PJ_DECL(pj_status_t) pjmedia_delay_buf_get(pjmedia_delay_buf *b,
pj_int16_t frame[]);
/**
* Reset delay buffer. This will clear the buffer's content. But keep
* the learning result.
*
* @param b The delay buffer.
*
* @return PJ_SUCCESS on success or the appropriate error.
*/
PJ_DECL(pj_status_t) pjmedia_delay_buf_reset(pjmedia_delay_buf *b);
/**
* Destroy delay buffer.
*
* @param b Delay buffer session.
*
* @return PJ_SUCCESS normally.
*/
PJ_DECL(pj_status_t) pjmedia_delay_buf_destroy(pjmedia_delay_buf *b);
PJ_END_DECL
/**
* @}
*/
#endif /* __PJMEDIA_DELAYBUF_H__ */
|