Mercurial > pidgin
comparison src/mediastreamer/msLPC10decoder.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 "msLPC10decoder.h" | |
| 23 #include "msLPC10encoder.h" | |
| 24 #include <stdlib.h> | |
| 25 #include <lpc10.h> | |
| 26 | |
| 27 extern MSFilter * ms_LPC10encoder_new(void); | |
| 28 | |
| 29 MSCodecInfo LPC10info={ | |
| 30 { | |
| 31 "LPC10-15 codec", | |
| 32 0, | |
| 33 MS_FILTER_AUDIO_CODEC, | |
| 34 ms_LPC10encoder_new, | |
| 35 "A low quality but very low bit rate codec from the U.S. Department of Defense." | |
| 36 }, | |
| 37 ms_LPC10encoder_new, | |
| 38 ms_LPC10decoder_new, | |
| 39 360, | |
| 40 7, | |
| 41 2400, | |
| 42 8000, | |
| 43 115, | |
| 44 "1015", | |
| 45 1, | |
| 46 1, | |
| 47 }; | |
| 48 | |
| 49 static MSLPC10DecoderClass *ms_LPC10decoder_class=NULL; | |
| 50 | |
| 51 MSFilter * ms_LPC10decoder_new(void) | |
| 52 { | |
| 53 MSLPC10Decoder *r; | |
| 54 | |
| 55 r=g_new(MSLPC10Decoder,1); | |
| 56 ms_LPC10decoder_init(r); | |
| 57 if (ms_LPC10decoder_class==NULL) | |
| 58 { | |
| 59 ms_LPC10decoder_class=g_new(MSLPC10DecoderClass,1); | |
| 60 ms_LPC10decoder_class_init(ms_LPC10decoder_class); | |
| 61 } | |
| 62 MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_LPC10decoder_class); | |
| 63 return(MS_FILTER(r)); | |
| 64 } | |
| 65 | |
| 66 | |
| 67 /* FOR INTERNAL USE*/ | |
| 68 void ms_LPC10decoder_init(MSLPC10Decoder *r) | |
| 69 { | |
| 70 ms_filter_init(MS_FILTER(r)); | |
| 71 MS_FILTER(r)->infifos=r->f_inputs; | |
| 72 MS_FILTER(r)->outfifos=r->f_outputs; | |
| 73 MS_FILTER(r)->r_mingran=7; | |
| 74 memset(r->f_inputs,0,sizeof(MSFifo*)*MSLPC10DECODER_MAX_INPUTS); | |
| 75 memset(r->f_outputs,0,sizeof(MSFifo*)*MSLPC10DECODER_MAX_INPUTS); | |
| 76 r->lpc10_dec=create_lpc10_decoder_state(); | |
| 77 } | |
| 78 | |
| 79 void ms_LPC10decoder_class_init(MSLPC10DecoderClass *klass) | |
| 80 { | |
| 81 ms_filter_class_init(MS_FILTER_CLASS(klass)); | |
| 82 ms_filter_class_set_name(MS_FILTER_CLASS(klass),"LPC10Dec"); | |
| 83 MS_FILTER_CLASS(klass)->max_finputs=MSLPC10DECODER_MAX_INPUTS; | |
| 84 MS_FILTER_CLASS(klass)->max_foutputs=MSLPC10DECODER_MAX_INPUTS; | |
| 85 MS_FILTER_CLASS(klass)->r_maxgran=7; | |
| 86 MS_FILTER_CLASS(klass)->w_maxgran=LPC10_SAMPLES_PER_FRAME*2; | |
| 87 MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_LPC10decoder_destroy; | |
| 88 MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_LPC10decoder_process; | |
| 89 MS_FILTER_CLASS(klass)->info=(MSFilterInfo*)&LPC10info; | |
| 90 } | |
| 91 | |
| 92 void ms_LPC10decoder_process(MSLPC10Decoder *r) | |
| 93 { | |
| 94 MSFifo *fi,*fo; | |
| 95 int err1; | |
| 96 void *s,*d; | |
| 97 float speech[LPC10_SAMPLES_PER_FRAME]; | |
| 98 INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; | |
| 99 | |
| 100 /* process output fifos, but there is only one for this class of filter*/ | |
| 101 | |
| 102 fi=r->f_inputs[0]; | |
| 103 fo=r->f_outputs[0]; | |
| 104 if (fi!=NULL) | |
| 105 { | |
| 106 err1=ms_fifo_get_read_ptr(fi,7,&s); | |
| 107 if (err1>0) | |
| 108 { | |
| 109 err1=ms_fifo_get_write_ptr(fo,LPC10_SAMPLES_PER_FRAME*2,&d); | |
| 110 if (d!=NULL) | |
| 111 { | |
| 112 read_bits(s, bits, LPC10_BITS_IN_COMPRESSED_FRAME); | |
| 113 lpc10_decode(bits,speech, r->lpc10_dec); | |
| 114 write_16bit_samples((INT16*)d, speech, LPC10_SAMPLES_PER_FRAME); | |
| 115 } | |
| 116 } | |
| 117 } | |
| 118 } | |
| 119 | |
| 120 void ms_LPC10decoder_uninit(MSLPC10Decoder *obj) | |
| 121 { | |
| 122 free(obj->lpc10_dec); | |
| 123 } | |
| 124 | |
| 125 void ms_LPC10decoder_destroy( MSLPC10Decoder *obj) | |
| 126 { | |
| 127 ms_LPC10decoder_uninit(obj); | |
| 128 g_free(obj); | |
| 129 } |
