Ejemplo n.º 1
0
/*! \brief decode frame into lin and fill output buffer. */
static int alawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
	int i = f->samples;
	unsigned char *src = f->data.ptr;
	int16_t *dst = pvt->outbuf.i16 + pvt->samples;

	pvt->samples += i;
	pvt->datalen += i * 2;	/* 2 bytes/sample */
	
	while (i--)
		*dst++ = AST_ALAW(*src++);

	return 0;
}
Ejemplo n.º 2
0
static int load_module(void)
{
	int res;
	int x;

	for (x=0;x<256;x++) {
		mu2a[x] = AST_LIN2A(AST_MULAW(x));
		a2mu[x] = AST_LIN2MU(AST_ALAW(x));
	}

	res = ast_register_translator(&alawtoulaw);
	res |= ast_register_translator(&ulawtoalaw);

	if (res) {
		unload_module();
		return AST_MODULE_LOAD_FAILURE;
	}

	return AST_MODULE_LOAD_SUCCESS;
}
Ejemplo n.º 3
0
static int load_module(void)
{
	int res;
	int x;

	ast_format_set(&alawtoulaw.src_format, AST_FORMAT_ALAW, 0);
	ast_format_set(&alawtoulaw.dst_format, AST_FORMAT_ULAW, 0);

	ast_format_set(&ulawtoalaw.src_format, AST_FORMAT_ULAW, 0);
	ast_format_set(&ulawtoalaw.dst_format, AST_FORMAT_ALAW, 0);

	for (x=0;x<256;x++) {
		mu2a[x] = AST_LIN2A(AST_MULAW(x));
		a2mu[x] = AST_LIN2MU(AST_ALAW(x));
	}
	res = ast_register_translator(&alawtoulaw);
	if (!res)
		res = ast_register_translator(&ulawtoalaw);
	else
		ast_unregister_translator(&alawtoulaw);
	if (res)
		return AST_MODULE_LOAD_FAILURE;
	return AST_MODULE_LOAD_SUCCESS;
}