Thu, 05 Jan 2006 05:29:51 +0000
[gaim-migrate @ 15077]
jabber.c:389: warning: ISO C90 forbids mixed declarations and code
| 12024 | 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 "msGSMencoder.h" | |
| 23 | #include "mscodec.h" | |
| 24 | ||
| 25 | extern MSCodecInfo GSMinfo; | |
| 26 | ||
| 27 | static MSGSMEncoderClass *ms_GSMencoder_class=NULL; | |
| 28 | ||
| 29 | MSFilter * ms_GSMencoder_new(void) | |
| 30 | { | |
| 31 | MSGSMEncoder *r; | |
| 32 | ||
| 33 | r=g_new(MSGSMEncoder,1); | |
| 34 | ms_GSMencoder_init(r); | |
| 35 | if (ms_GSMencoder_class==NULL) | |
| 36 | { | |
| 37 | ms_GSMencoder_class=g_new(MSGSMEncoderClass,1); | |
| 38 | ms_GSMencoder_class_init(ms_GSMencoder_class); | |
| 39 | } | |
| 40 | MS_FILTER(r)->klass=MS_FILTER_CLASS(ms_GSMencoder_class); | |
| 41 | return(MS_FILTER(r)); | |
| 42 | } | |
| 43 | ||
| 44 | ||
| 45 | /* FOR INTERNAL USE*/ | |
| 46 | void ms_GSMencoder_init(MSGSMEncoder *r) | |
| 47 | { | |
| 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=2*160; | |
| 52 | memset(r->f_inputs,0,sizeof(MSFifo*)*MSGSMENCODER_MAX_INPUTS); | |
| 53 | memset(r->f_outputs,0,sizeof(MSFifo*)*MSGSMENCODER_MAX_INPUTS); | |
| 54 | r->gsm_handle=gsm_create(); | |
| 55 | } | |
| 56 | ||
| 57 | void ms_GSMencoder_class_init(MSGSMEncoderClass *klass) | |
| 58 | { | |
| 59 | ms_filter_class_init(MS_FILTER_CLASS(klass)); | |
| 60 | ms_filter_class_set_name(MS_FILTER_CLASS(klass),"GSMEncoder"); | |
| 61 | MS_FILTER_CLASS(klass)->max_finputs=MSGSMENCODER_MAX_INPUTS; | |
| 62 | MS_FILTER_CLASS(klass)->max_foutputs=MSGSMENCODER_MAX_INPUTS; | |
| 63 | MS_FILTER_CLASS(klass)->r_maxgran=2*160; | |
| 64 | MS_FILTER_CLASS(klass)->w_maxgran=33; | |
| 65 | MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_GSMencoder_destroy; | |
| 66 | MS_FILTER_CLASS(klass)->process=(MSFilterProcessFunc)ms_GSMencoder_process; | |
| 67 | MS_FILTER_CLASS(klass)->info=MS_FILTER_INFO(&GSMinfo); | |
| 68 | } | |
| 69 | ||
| 70 | void ms_GSMencoder_process(MSGSMEncoder *r) | |
| 71 | { | |
| 72 | MSFifo *fi,*fo; | |
| 73 | int err1; | |
| 74 | void *s,*d; | |
| 75 | ||
| 76 | /* process output fifos, but there is only one for this class of filter*/ | |
| 77 | ||
| 78 | fi=r->f_inputs[0]; | |
| 79 | fo=r->f_outputs[0]; | |
| 80 | if (fi!=NULL) | |
| 81 | { | |
| 82 | err1=ms_fifo_get_read_ptr(fi,160*2,&s); | |
| 83 | if (err1>0) | |
| 84 | { | |
| 85 | err1=ms_fifo_get_write_ptr(fo,33,&d); | |
| 86 | if (d!=NULL) gsm_encode(r->gsm_handle,(gsm_signal*)s,(gsm_byte*)d); | |
| 87 | } | |
| 88 | ||
| 89 | } | |
| 90 | } | |
| 91 | ||
| 92 | void ms_GSMencoder_uninit(MSGSMEncoder *obj) | |
| 93 | { | |
| 94 | gsm_destroy(obj->gsm_handle); | |
| 95 | } | |
| 96 | ||
| 97 | void ms_GSMencoder_destroy( MSGSMEncoder *obj) | |
| 98 | { | |
| 99 | ms_GSMencoder_uninit(obj); | |
| 100 | g_free(obj); | |
| 101 | } |