2
The mediastreamer library aims at providing modular media processing and I/O
3
for linphone, but also for any telephony application.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include "msMUlawenc.h"
23
#include "g711common.h"
25
extern MSCodecInfo MULAWinfo;
27
static MSMULAWEncoderClass *ms_MULAWencoder_class=NULL;
29
MSFilter * ms_MULAWencoder_new(void)
33
r=g_new(MSMULAWEncoder,1);
34
ms_MULAWencoder_init(r);
35
if (ms_MULAWencoder_class==NULL)
37
ms_MULAWencoder_class=g_new(MSMULAWEncoderClass,1);
38
ms_MULAWencoder_class_init(ms_MULAWencoder_class);
40
MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_MULAWencoder_class);
46
void ms_MULAWencoder_init(MSMULAWEncoder *r)
48
ms_filter_init(MS_FILTER(r));
49
MS_FILTER(r)->infifos=r->f_inputs;
50
MS_FILTER(r)->outfifos=r->f_outputs;
51
MS_FILTER(r)->r_mingran=MULAW_ENCODER_RMAXGRAN; /* the filter can be called as soon as there is
52
something to process */
53
memset(r->f_inputs,0,sizeof(MSFifo*)*MSMULAWENCODER_MAX_INPUTS);
54
memset(r->f_outputs,0,sizeof(MSFifo*)*MSMULAWENCODER_MAX_INPUTS);
58
void ms_MULAWencoder_class_init(MSMULAWEncoderClass *klass)
60
ms_filter_class_init(MS_FILTER_CLASS(klass));
61
ms_filter_class_set_name(MS_FILTER_CLASS(klass),"MULAWEncoder");
62
MS_FILTER_CLASS(klass)->info=(MSFilterInfo*)&MULAWinfo;
63
MS_FILTER_CLASS(klass)->max_finputs=MSMULAWENCODER_MAX_INPUTS;
64
MS_FILTER_CLASS(klass)->max_foutputs=MSMULAWENCODER_MAX_INPUTS;
65
MS_FILTER_CLASS(klass)->r_maxgran=MULAW_ENCODER_RMAXGRAN;
66
MS_FILTER_CLASS(klass)->w_maxgran=MULAW_ENCODER_WMAXGRAN;
67
MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_MULAWencoder_destroy;
68
MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_MULAWencoder_process;
71
void ms_MULAWencoder_process(MSMULAWEncoder *r)
77
/* process output fifos, but there is only one for this class of filter*/
81
inlen=ms_fifo_get_read_ptr(fi,MULAW_ENCODER_RMAXGRAN,(void**)&s);
82
outlen=ms_fifo_get_write_ptr(fo,MULAW_ENCODER_WMAXGRAN,(void**)&d);
85
for(i=0;i<MULAW_ENCODER_WMAXGRAN;i++)
87
d[i]=s16_to_ulaw( *((gint16*)s) );
91
else g_warning("MSMULAWDecoder: Discarding samples !!");
96
void ms_MULAWencoder_destroy( MSMULAWEncoder *obj)