Ejemplo n.º 1
0
static int load_module(void *mod)
{
	int index;

	/* XXX better init ? */
	for (index = 0; index < (sizeof(ulaw_silence) / sizeof(ulaw_silence[0])); index++)
		ulaw_silence[index] = AST_LIN2MU(0);
	for (index = 0; index < (sizeof(alaw_silence) / sizeof(alaw_silence[0])); index++)
		alaw_silence[index] = AST_LIN2A(0);

	return ast_format_register(&pcm_f) || ast_format_register(&alaw_f)
		|| ast_format_register(&au_f);
}
Ejemplo n.º 2
0
/*! \brief convert and store input samples in output buffer */
static int lintoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
{
	int i = f->samples;
	char *dst = pvt->outbuf.c + pvt->samples;
	int16_t *src = f->data.ptr;

	pvt->samples += i;
	pvt->datalen += i;	/* 1 byte/sample */

	while (i--) 
		*dst++ = AST_LIN2A(*src++);

	return 0;
}
int load_module()
{
	int index;

	for (index = 0; index < (sizeof(alaw_silence) / sizeof(alaw_silence[0])); index++)
		alaw_silence[index] = AST_LIN2A(0);

	return ast_format_register(name, exts, AST_FORMAT_ALAW,
				   pcm_open,
				   pcm_rewrite,
				   pcm_write,
				   pcm_seek,
				   pcm_trunc,
				   pcm_tell,
				   pcm_read,
				   pcm_close,
				   pcm_getcomment);
}
Ejemplo n.º 4
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;
}
static int load_module(void)
{
	int i;

	/* XXX better init ? */
	for (i = 0; i < ARRAY_LEN(ulaw_silence); i++)
		ulaw_silence[i] = AST_LIN2MU(0);
	for (i = 0; i < ARRAY_LEN(alaw_silence); i++)
		alaw_silence[i] = AST_LIN2A(0);

	ast_format_set(&pcm_f.format, AST_FORMAT_ULAW, 0);
	ast_format_set(&alaw_f.format, AST_FORMAT_ALAW, 0);
	ast_format_set(&au_f.format, AST_FORMAT_ULAW, 0);
	ast_format_set(&g722_f.format, AST_FORMAT_G722, 0);
	if ( ast_format_def_register(&pcm_f)
		|| ast_format_def_register(&alaw_f)
		|| ast_format_def_register(&au_f)
		|| ast_format_def_register(&g722_f) )
		return AST_MODULE_LOAD_FAILURE;
	return AST_MODULE_LOAD_SUCCESS;
}
Ejemplo n.º 6
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;
}