mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
Merge codec_consistency branch. This should make sample usage much happier.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@150729 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -47,15 +47,15 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||
|
||||
#include "../formats/msgsm.h"
|
||||
|
||||
/* Sample frame data */
|
||||
#include "slin_gsm_ex.h"
|
||||
#include "gsm_slin_ex.h"
|
||||
|
||||
#define BUFFER_SAMPLES 8000
|
||||
#define GSM_SAMPLES 160
|
||||
#define GSM_FRAME_LEN 33
|
||||
#define MSGSM_FRAME_LEN 65
|
||||
|
||||
/* Sample frame data */
|
||||
#include "asterisk/slin.h"
|
||||
#include "ex_gsm.h"
|
||||
|
||||
struct gsm_translator_pvt { /* both gsm2lin and lin2gsm */
|
||||
gsm gsm;
|
||||
int16_t buf[BUFFER_SAMPLES]; /* lin2gsm, temporary storage */
|
||||
@@ -68,36 +68,6 @@ static int gsm_new(struct ast_trans_pvt *pvt)
|
||||
return (tmp->gsm = gsm_create()) ? 0 : -1;
|
||||
}
|
||||
|
||||
static struct ast_frame *lintogsm_sample(void)
|
||||
{
|
||||
static struct ast_frame f;
|
||||
f.frametype = AST_FRAME_VOICE;
|
||||
f.subclass = AST_FORMAT_SLINEAR;
|
||||
f.datalen = sizeof(slin_gsm_ex);
|
||||
/* Assume 8000 Hz */
|
||||
f.samples = sizeof(slin_gsm_ex)/2;
|
||||
f.mallocd = 0;
|
||||
f.offset = 0;
|
||||
f.src = __PRETTY_FUNCTION__;
|
||||
f.data.ptr = slin_gsm_ex;
|
||||
return &f;
|
||||
}
|
||||
|
||||
static struct ast_frame *gsmtolin_sample(void)
|
||||
{
|
||||
static struct ast_frame f;
|
||||
f.frametype = AST_FRAME_VOICE;
|
||||
f.subclass = AST_FORMAT_GSM;
|
||||
f.datalen = sizeof(gsm_slin_ex);
|
||||
/* All frames are 20 ms long */
|
||||
f.samples = GSM_SAMPLES;
|
||||
f.mallocd = 0;
|
||||
f.offset = 0;
|
||||
f.src = __PRETTY_FUNCTION__;
|
||||
f.data.ptr = gsm_slin_ex;
|
||||
return &f;
|
||||
}
|
||||
|
||||
/*! \brief decode and store in outbuf. */
|
||||
static int gsmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
||||
{
|
||||
@@ -203,7 +173,7 @@ static struct ast_translator gsmtolin = {
|
||||
.newpvt = gsm_new,
|
||||
.framein = gsmtolin_framein,
|
||||
.destroy = gsm_destroy_stuff,
|
||||
.sample = gsmtolin_sample,
|
||||
.sample = gsm_sample,
|
||||
.buffer_samples = BUFFER_SAMPLES,
|
||||
.buf_size = BUFFER_SAMPLES * 2,
|
||||
.desc_size = sizeof (struct gsm_translator_pvt ),
|
||||
@@ -218,7 +188,7 @@ static struct ast_translator lintogsm = {
|
||||
.framein = lintogsm_framein,
|
||||
.frameout = lintogsm_frameout,
|
||||
.destroy = gsm_destroy_stuff,
|
||||
.sample = lintogsm_sample,
|
||||
.sample = slin8_sample,
|
||||
.desc_size = sizeof (struct gsm_translator_pvt ),
|
||||
.buf_size = (BUFFER_SAMPLES * GSM_FRAME_LEN + GSM_SAMPLES - 1)/GSM_SAMPLES,
|
||||
};
|
||||
|
Reference in New Issue
Block a user