Mercurial > pidgin
comparison src/mediastreamer/msAlawdec.c @ 12024:e67993da8a22
[gaim-migrate @ 14317]
I strongly suspect CruiseControl is going to yell at me for this.
A voice chat API, GUI + mediastreamer. This is what I'm using for Google Talk.
This doesn't actually do anything at all. There's no code in the Jabber plugin yet
to use this API (although it Works For Me). All it will do is compile and link.
If you're lucky.
To build this, you should install oRTP from Linphone, Speex and iLBC (also
from linphone, I believe). To not build this, ./configure --disable-vv.
Most of the configure.ac and Makefile.am hackery was lifted right out of
Linphone with a few modifications. It seems to work if you have everything
installed or if you --disable-vv. I haven't really tested not having
everything installed and not --disabling-vv.
It's kinda funky to include all of mediastreamer in the source tree like this,
but linphone doesn't build it as a separate library. I'll probably wind up
writing them a patch to build it as a .so so we can link it dynamically instead.
This code certainly isn't finished. It'll adapt as I progress on the Google code,
but it's certainly of more use here in CVS than in my personal tree.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 09 Nov 2005 08:07:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
12023:80faf1ca5280 | 12024:e67993da8a22 |
---|---|
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 <msAlawdec.h> | |
23 #include <g711common.h> | |
24 | |
25 extern MSFilter * ms_ALAWencoder_new(void); | |
26 | |
27 MSCodecInfo ALAWinfo={ | |
28 { | |
29 "ALAW codec", | |
30 0, | |
31 MS_FILTER_AUDIO_CODEC, | |
32 ms_ALAWencoder_new, | |
33 "This is the classic A-law codec. Good quality, but only usable with high speed network connections." | |
34 }, | |
35 ms_ALAWencoder_new, | |
36 ms_ALAWdecoder_new, | |
37 320, | |
38 160, | |
39 64000, | |
40 8000, | |
41 8, | |
42 "PCMA", | |
43 1, | |
44 1, | |
45 }; | |
46 | |
47 static MSALAWDecoderClass *ms_ALAWdecoder_class=NULL; | |
48 | |
49 MSFilter * ms_ALAWdecoder_new(void) | |
50 { | |
51 MSALAWDecoder *r; | |
52 | |
53 r=g_new(MSALAWDecoder,1); | |
54 ms_ALAWdecoder_init(r); | |
55 if (ms_ALAWdecoder_class==NULL) | |
56 { | |
57 ms_ALAWdecoder_class=g_new(MSALAWDecoderClass,1); | |
58 ms_ALAWdecoder_class_init(ms_ALAWdecoder_class); | |
59 } | |
60 MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_ALAWdecoder_class); | |
61 return(MS_FILTER(r)); | |
62 } | |
63 | |
64 | |
65 /* FOR INTERNAL USE*/ | |
66 void ms_ALAWdecoder_init(MSALAWDecoder *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=ALAW_DECODER_RMAXGRAN; | |
72 memset(r->f_inputs,0,sizeof(MSFifo*)*MSALAWDECODER_MAX_INPUTS); | |
73 memset(r->f_outputs,0,sizeof(MSFifo*)*MSALAWDECODER_MAX_INPUTS); | |
74 | |
75 } | |
76 | |
77 void ms_ALAWdecoder_class_init(MSALAWDecoderClass *klass) | |
78 { | |
79 ms_filter_class_init(MS_FILTER_CLASS(klass)); | |
80 ms_filter_class_set_name(MS_FILTER_CLASS(klass),"ALAWDecoder"); | |
81 MS_FILTER_CLASS(klass)->info=(MSFilterInfo*)&ALAWinfo; | |
82 MS_FILTER_CLASS(klass)->max_finputs=MSALAWDECODER_MAX_INPUTS; | |
83 MS_FILTER_CLASS(klass)->max_foutputs=MSALAWDECODER_MAX_INPUTS; | |
84 MS_FILTER_CLASS(klass)->r_maxgran=ALAW_DECODER_RMAXGRAN; | |
85 MS_FILTER_CLASS(klass)->w_maxgran=ALAW_DECODER_WMAXGRAN; | |
86 MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_ALAWdecoder_destroy; | |
87 MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_ALAWdecoder_process; | |
88 } | |
89 | |
90 void ms_ALAWdecoder_process(MSALAWDecoder *r) | |
91 { | |
92 MSFifo *fi,*fo; | |
93 int inlen,outlen; | |
94 gchar *s,*d; | |
95 int i; | |
96 /* process output fifos, but there is only one for this class of filter*/ | |
97 | |
98 /* this is the simplest process function design: | |
99 the filter declares a r_mingran of ALAW_DECODER_RMAXGRAN, so the mediastreamer's | |
100 scheduler will call the process function each time there is ALAW_DECODER_RMAXGRAN | |
101 bytes to read in the input fifo. If there is more, then it will call it several | |
102 time in order to the fifo to be completetly processed. | |
103 This is very simple, but not very efficient because of the multiple call function | |
104 of MSFilterProcessFunc that may happen. | |
105 The MSAlawEncoder implements another design; see it. | |
106 */ | |
107 | |
108 fi=r->f_inputs[0]; | |
109 fo=r->f_outputs[0]; | |
110 g_return_if_fail(fi!=NULL); | |
111 g_return_if_fail(fo!=NULL); | |
112 | |
113 inlen=ms_fifo_get_read_ptr(fi,ALAW_DECODER_RMAXGRAN,(void**)&s); | |
114 if (s==NULL) return; | |
115 outlen=ms_fifo_get_write_ptr(fo,ALAW_DECODER_WMAXGRAN,(void**)&d); | |
116 if (d!=NULL) | |
117 { | |
118 for(i=0;i<ALAW_DECODER_RMAXGRAN;i++) | |
119 { | |
120 ((gint16*)d)[i]=alaw_to_s16( (unsigned char) s[i]); | |
121 } | |
122 } | |
123 else g_warning("MSALAWDecoder: Discarding samples !!"); | |
124 | |
125 } | |
126 | |
127 | |
128 | |
129 void ms_ALAWdecoder_destroy( MSALAWDecoder *obj) | |
130 { | |
131 g_free(obj); | |
132 } |