src/mediastreamer/msGSMdecoder.c

branch
gaim
changeset 20470
77693555855f
parent 13071
b98e72d4089a
parent 20469
b2836a24d81e
child 20471
1966704b3e42
equal deleted inserted replaced
13071:b98e72d4089a 20470:77693555855f
1 /*
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
5
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.
10
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.
15
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
19 */
20
21
22 #include "msGSMdecoder.h"
23
24 extern MSFilter * ms_GSMencoder_new(void);
25
26 MSCodecInfo GSMinfo={
27 {
28 "GSM codec",
29 0,
30 MS_FILTER_AUDIO_CODEC,
31 ms_GSMencoder_new,
32 "This is the codec widely used in european mobile phones. This implementation was done by "
33 "Jutta Degener and Carsten Bormann."
34 },
35 ms_GSMencoder_new,
36 ms_GSMdecoder_new,
37 320,
38 33,
39 13800,
40 8000,
41 3,
42 "GSM",
43 1,
44 1,
45 };
46
47 static MSGSMDecoderClass *ms_GSMdecoder_class=NULL;
48
49 MSFilter * ms_GSMdecoder_new(void)
50 {
51 MSGSMDecoder *r;
52
53 r=g_new(MSGSMDecoder,1);
54 ms_GSMdecoder_init(r);
55 if (ms_GSMdecoder_class==NULL)
56 {
57 ms_GSMdecoder_class=g_new(MSGSMDecoderClass,1);
58 ms_GSMdecoder_class_init(ms_GSMdecoder_class);
59 }
60 MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_GSMdecoder_class);
61 return(MS_FILTER(r));
62 }
63
64
65 /* FOR INTERNAL USE*/
66 void ms_GSMdecoder_init(MSGSMDecoder *r)
67 {
68 ms_filter_init(MS_FILTER(r));
69 MS_FILTER(r)->infifos=r->f_inputs;
70 MS_FILTER(r)->outfifos=r->f_outputs;
71 MS_FILTER(r)->r_mingran=33;
72 memset(r->f_inputs,0,sizeof(MSFifo*)*MSGSMDECODER_MAX_INPUTS);
73 memset(r->f_outputs,0,sizeof(MSFifo*)*MSGSMDECODER_MAX_INPUTS);
74 r->gsm_handle=gsm_create();
75 }
76
77 void ms_GSMdecoder_class_init(MSGSMDecoderClass *klass)
78 {
79 ms_filter_class_init(MS_FILTER_CLASS(klass));
80 ms_filter_class_set_name(MS_FILTER_CLASS(klass),"GSMDecoder");
81 MS_FILTER_CLASS(klass)->info=(MSFilterInfo*)&GSMinfo;
82 MS_FILTER_CLASS(klass)->max_finputs=MSGSMDECODER_MAX_INPUTS;
83 MS_FILTER_CLASS(klass)->max_foutputs=MSGSMDECODER_MAX_INPUTS;
84 MS_FILTER_CLASS(klass)->r_maxgran=33;
85 MS_FILTER_CLASS(klass)->w_maxgran=2*160;
86 MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_GSMdecoder_destroy;
87 MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_GSMdecoder_process;
88 }
89
90 void ms_GSMdecoder_process(MSGSMDecoder *r)
91 {
92 MSFifo *fi,*fo;
93 int err1;
94 void *s,*d;
95
96 /* process output fifos, but there is only one for this class of filter*/
97
98 fi=r->f_inputs[0];
99 fo=r->f_outputs[0];
100 if (fi!=NULL)
101 {
102 err1=ms_fifo_get_read_ptr(fi,33,&s);
103 if (err1>0)
104 {
105 err1=ms_fifo_get_write_ptr(fo,160*2,&d);
106 if (d!=NULL) gsm_decode(r->gsm_handle,s,(gsm_signal*)d);
107 }
108
109 }
110 }
111
112 void ms_GSMdecoder_uninit(MSGSMDecoder *obj)
113 {
114 gsm_destroy(obj->gsm_handle);
115 }
116
117 void ms_GSMdecoder_destroy( MSGSMDecoder *obj)
118 {
119 ms_GSMdecoder_uninit(obj);
120 g_free(obj);
121 }

mercurial