comparison src/mediastreamer/mstruespeechdecoder.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 Copyright 2003 Robert W. Brewer <rbrewer at op.net>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20 #include "mstruespeechdecoder.h"
21 #include "mscodec.h"
22
23 MSCodecInfo TrueSpeechinfo =
24 {
25 {
26 "TrueSpeech codec",
27 0,
28 MS_FILTER_AUDIO_CODEC,
29 ms_truespeechencoder_new,
30 "This is a proprietary codec by the DSP Group that is used in some "
31 "Windows applications. It has a good quality and bitrate. "
32 "It requires the Windows DLLs tssoft32.acm and "
33 "tsd32.dll to be available."
34 },
35 ms_truespeechencoder_new,
36 ms_truespeechdecoder_new,
37 480,
38 32,
39 8536,
40 8000,
41 116,
42 "TSP0",
43 1,
44 1,
45 };
46
47
48 static MSTrueSpeechDecoderClass *ms_truespeechdecoder_class = 0;
49
50 /* FOR INTERNAL USE*/
51 void ms_truespeechdecoder_init(MSTrueSpeechDecoder *r);
52 void ms_truespeechdecoder_class_init(MSTrueSpeechDecoderClass *klass);
53 void ms_truespeechdecoder_destroy(MSTrueSpeechDecoder *obj);
54 void ms_truespeechdecoder_process(MSTrueSpeechDecoder *r);
55
56 MSFilter * ms_truespeechdecoder_new(void)
57 {
58 MSTrueSpeechDecoder *r = 0;
59
60 if (!ms_truespeechdecoder_class)
61 {
62 ms_truespeechdecoder_class = g_new(MSTrueSpeechDecoderClass, 1);
63 ms_truespeechdecoder_class_init(ms_truespeechdecoder_class);
64 }
65
66 r = g_new(MSTrueSpeechDecoder, 1);
67 MS_FILTER(r)->klass = MS_FILTER_CLASS(ms_truespeechdecoder_class);
68 ms_truespeechdecoder_init(r);
69 return MS_FILTER(r);
70 }
71
72
73 /* FOR INTERNAL USE*/
74 void ms_truespeechdecoder_init(MSTrueSpeechDecoder *r)
75 {
76 ms_filter_init(MS_FILTER(r));
77 MS_FILTER(r)->infifos = r->f_inputs;
78 MS_FILTER(r)->outfifos = r->f_outputs;
79
80 WAVEFORMATEX* wf = ms_truespeechencoder_wf_create();
81
82 r->codec = win32codec_create(wf, 0);
83 free(wf);
84
85 MS_FILTER(r)->r_mingran = r->codec->min_insize;
86
87 MS_FILTER_CLASS(ms_truespeechdecoder_class)->r_maxgran =
88 r->codec->min_insize;
89 MS_FILTER_CLASS(ms_truespeechdecoder_class)->w_maxgran =
90 r->codec->min_outsize;
91
92 memset(r->f_inputs, 0, sizeof(MSFifo*) * MS_TRUESPEECH_CODEC_MAX_IN_OUT);
93 memset(r->f_outputs, 0, sizeof(MSFifo*) * MS_TRUESPEECH_CODEC_MAX_IN_OUT);
94 }
95
96 void ms_truespeechdecoder_class_init(MSTrueSpeechDecoderClass *klass)
97 {
98 ms_filter_class_init(MS_FILTER_CLASS(klass));
99 ms_filter_class_set_name(MS_FILTER_CLASS(klass), "TrueSpeechDecoder");
100 MS_FILTER_CLASS(klass)->max_finputs = MS_TRUESPEECH_CODEC_MAX_IN_OUT;
101 MS_FILTER_CLASS(klass)->max_foutputs = MS_TRUESPEECH_CODEC_MAX_IN_OUT;
102 MS_FILTER_CLASS(klass)->r_maxgran = 0; /* filled in by first instance */
103 MS_FILTER_CLASS(klass)->w_maxgran = 0; /* filled in by first instance */
104 MS_FILTER_CLASS(klass)->destroy = (MSFilterDestroyFunc)ms_truespeechdecoder_destroy;
105 MS_FILTER_CLASS(klass)->process = (MSFilterProcessFunc)ms_truespeechdecoder_process;
106 MS_FILTER_CLASS(klass)->info = MS_FILTER_INFO(&TrueSpeechinfo);
107 klass->driver = win32codec_create_driver(TRUESPEECH_DLL,
108 TRUESPEECH_FORMAT_TAG, 0);
109 }
110
111 void ms_truespeechdecoder_process(MSTrueSpeechDecoder *r)
112 {
113 MSFifo *fi,*fo;
114 gint err1;
115 void *s,*d;
116
117 /* process output fifos, but there is only one for this class of filter*/
118
119 fi = r->f_inputs[0];
120 fo = r->f_outputs[0];
121 if (fi)
122 {
123 err1 = ms_fifo_get_read_ptr(fi, r->codec->min_insize, &s);
124 if (err1 > 0)
125 {
126 err1 = ms_fifo_get_write_ptr(fo, r->codec->min_outsize, &d);
127 if (d)
128 {
129 signed long n;
130 n = win32codec_convert(r->codec,
131 s, r->codec->min_insize,
132 d, r->codec->min_outsize);
133 }
134 }
135
136 }
137 }
138
139
140
141 void ms_truespeechdecoder_uninit(MSTrueSpeechDecoder *obj)
142 {
143 win32codec_destroy(obj->codec);
144 }
145
146 void ms_truespeechdecoder_destroy(MSTrueSpeechDecoder *obj)
147 {
148 ms_truespeechdecoder_uninit(obj);
149 g_free(obj);
150 }
151
152