38 #include "asterisk/translate.h"
43 #include "lpc10/lpc10.h"
54 #define LPC10_BYTES_IN_COMPRESSED_FRAME (LPC10_BITS_IN_COMPRESSED_FRAME + 7)/8
56 #define BUFFER_SAMPLES 8000
60 struct lpc10_encoder_state *
enc;
61 struct lpc10_decoder_state *
dec;
72 return (tmp->
lpc10.
enc = create_lpc10_encoder_state()) ? 0 : -1;
79 return (tmp->
lpc10.
dec = create_lpc10_decoder_state()) ? 0 : -1;
85 for (x=0;x<LPC10_BITS_IN_COMPRESSED_FRAME;x++) {
86 if (*c & (0x80 >> (x & 7)))
98 unsigned char mask=0x80;
101 for (x=0;x<LPC10_BITS_IN_COMPRESSED_FRAME;x++) {
119 while (len + LPC10_BYTES_IN_COMPRESSED_FRAME <= f->datalen) {
121 float tmpbuf[LPC10_SAMPLES_PER_FRAME];
122 INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
128 if (lpc10_decode(bits, tmpbuf, tmp->
lpc10.
dec)) {
132 for (x=0;x<LPC10_SAMPLES_PER_FRAME;x++) {
134 dst[pvt->
samples + x] = (int16_t)(32768.0 * tmpbuf[x]);
137 pvt->
samples += LPC10_SAMPLES_PER_FRAME;
138 pvt->
datalen += 2*LPC10_SAMPLES_PER_FRAME;
142 printf(
"Decoded %d, expected %d\n", len, f->
datalen);
166 float tmpbuf[LPC10_SAMPLES_PER_FRAME];
167 INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME];
169 if (pvt->
samples < LPC10_SAMPLES_PER_FRAME)
171 while (pvt->
samples >= LPC10_SAMPLES_PER_FRAME) {
173 for (x=0;x<LPC10_SAMPLES_PER_FRAME;x++)
174 tmpbuf[x] = (
float)tmp->
buf[x + samples] / 32768.0;
175 lpc10_encode(tmpbuf, bits, tmp->
lpc10.
enc);
178 samples += LPC10_SAMPLES_PER_FRAME;
179 pvt->
samples -= LPC10_SAMPLES_PER_FRAME;
199 .
name =
"lpc10tolin",
212 .
name =
"lintolpc10",
struct ast_frame * ast_trans_frameout(struct ast_trans_pvt *pvt, int datalen, int samples)
generic frameout function
int datalen
actual space used in outbuf
#define LPC10_BYTES_IN_COMPRESSED_FRAME
Asterisk main include file. File version handling, generic pbx functions.
static int lpc10tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
union ast_trans_pvt::@213 outbuf
Descriptor of a translator.
static int lpc10_enc_new(struct ast_trans_pvt *pvt)
static struct ast_translator lpc10tolin
Configuration File Parser.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static struct ast_frame * slin8_sample(void)
static int lintolpc10_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
short buf[BUFFER_SAMPLES]
static struct ast_translator lintolpc10
#define ast_register_translator(t)
See __ast_register_translator()
int ast_unregister_translator(struct ast_translator *t)
Unregister a translator Unregisters the given tranlator.
struct lpc10_encoder_state * enc
static struct ast_frame * lintolpc10_frameout(struct ast_trans_pvt *pvt)
static void lpc10_destroy(struct ast_trans_pvt *arg)
static void extract_bits(INT32 *bits, unsigned char *c)
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_frame * lpc10_sample(void)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
union lpc10_coder_pvt::@128 lpc10
static int lpc10_dec_new(struct ast_trans_pvt *pvt)
Copyright (C) 2008, Digium, Inc.
static int unload_module(void)
static void build_bits(unsigned char *c, INT32 *bits)
#define AST_FORMAT_SLINEAR
Data structure associated with a single frame of data.
struct lpc10_decoder_state * dec
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
union ast_frame::@172 data
static int load_module(void)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.