Mercurial > pidgin.yaz
comparison src/mediastreamer/sndcard.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 "sndcard.h" | |
23 #include "msfilter.h" | |
24 | |
25 void snd_card_init(SndCard *obj) | |
26 { | |
27 memset(obj,0,sizeof(SndCard)); | |
28 } | |
29 | |
30 void snd_card_uninit(SndCard *obj) | |
31 { | |
32 if (obj->card_name!=NULL) g_free(obj->card_name); | |
33 } | |
34 | |
35 const gchar *snd_card_get_identifier(SndCard *obj) | |
36 { | |
37 return obj->card_name; | |
38 } | |
39 | |
40 int snd_card_open_r(SndCard *obj, int bits, int stereo, int rate) | |
41 { | |
42 g_return_val_if_fail(obj->_open_r!=NULL,-1); | |
43 g_message("Opening sound card [%s] in capture mode with stereo=%i,rate=%i,bits=%i",obj->card_name,stereo,rate,bits); | |
44 return obj->_open_r(obj,bits,stereo,rate); | |
45 } | |
46 int snd_card_open_w(SndCard *obj, int bits, int stereo, int rate) | |
47 { | |
48 g_return_val_if_fail(obj->_open_w!=NULL,-1); | |
49 g_message("Opening sound card [%s] in playback mode with stereo=%i,rate=%i,bits=%i",obj->card_name,stereo,rate,bits); | |
50 return obj->_open_w(obj,bits,stereo,rate); | |
51 } | |
52 | |
53 gboolean snd_card_can_read(SndCard *obj){ | |
54 g_return_val_if_fail(obj->_can_read!=NULL,-1); | |
55 return obj->_can_read(obj); | |
56 } | |
57 | |
58 void snd_card_set_blocking_mode(SndCard *obj,gboolean yesno){ | |
59 g_return_if_fail(obj->_set_blocking_mode!=NULL); | |
60 obj->_set_blocking_mode(obj,yesno); | |
61 } | |
62 | |
63 int snd_card_read(SndCard *obj,char *buffer,int size) | |
64 { | |
65 g_return_val_if_fail(obj->_read!=NULL,-1); | |
66 return obj->_read(obj,buffer,size); | |
67 } | |
68 int snd_card_write(SndCard *obj,char *buffer,int size) | |
69 { | |
70 g_return_val_if_fail(obj->_write!=NULL,-1); | |
71 return obj->_write(obj,buffer,size); | |
72 } | |
73 | |
74 int snd_card_get_bsize(SndCard *obj) | |
75 { | |
76 if (obj->flags & SND_CARD_FLAGS_OPENED){ | |
77 return obj->bsize; | |
78 } | |
79 return -1; | |
80 } | |
81 | |
82 void snd_card_close_r(SndCard *obj) | |
83 { | |
84 g_return_if_fail(obj->_close_r!=NULL); | |
85 g_message("Closing reading channel of soundcard."); | |
86 obj->_close_r(obj); | |
87 } | |
88 | |
89 void snd_card_close_w(SndCard *obj) | |
90 { | |
91 g_return_if_fail(obj->_close_w!=NULL); | |
92 g_message("Closing writing channel of soundcard."); | |
93 obj->_close_w(obj); | |
94 } | |
95 | |
96 gint snd_card_probe(SndCard *obj,int bits, int stereo, int rate) | |
97 { | |
98 g_return_val_if_fail(obj->_probe!=NULL,-1); | |
99 return obj->_probe(obj,bits,stereo,rate); | |
100 } | |
101 | |
102 void snd_card_set_rec_source(SndCard *obj, int source) | |
103 { | |
104 g_return_if_fail(obj->_set_rec_source!=NULL); | |
105 obj->_set_rec_source(obj,source); | |
106 } | |
107 | |
108 void snd_card_set_level(SndCard *obj, int way, int level) | |
109 { | |
110 g_return_if_fail(obj->_set_level!=NULL); | |
111 obj->_set_level(obj,way,level); | |
112 } | |
113 | |
114 gint snd_card_get_level(SndCard *obj,int way) | |
115 { | |
116 g_return_val_if_fail(obj->_get_level!=NULL,-1); | |
117 return obj->_get_level(obj,way); | |
118 } | |
119 | |
120 | |
121 MSFilter * snd_card_create_read_filter(SndCard *obj) | |
122 { | |
123 g_return_val_if_fail(obj->_create_read_filter!=NULL,NULL); | |
124 return obj->_create_read_filter(obj); | |
125 } | |
126 MSFilter * snd_card_create_write_filter(SndCard *obj) | |
127 { | |
128 g_return_val_if_fail(obj->_create_write_filter!=NULL,NULL); | |
129 return obj->_create_write_filter(obj); | |
130 } | |
131 | |
132 | |
133 #ifdef HAVE_SYS_AUDIO_H | |
134 gint sys_audio_manager_init(SndCardManager *manager, gint index) | |
135 { | |
136 /* this is a quick shortcut, as multiple soundcards on HPUX does not happen | |
137 very often... */ | |
138 manager->cards[index]=hpux_snd_card_new("/dev/audio","/dev/audio"); | |
139 return 1; | |
140 } | |
141 | |
142 #endif | |
143 | |
144 #include "osscard.h" | |
145 #include "alsacard.h" | |
146 #include "jackcard.h" | |
147 | |
148 void snd_card_manager_init(SndCardManager *manager) | |
149 { | |
150 gint index=0; | |
151 gint tmp=0; | |
152 memset(manager,0,sizeof(SndCardManager)); | |
153 #ifdef HAVE_SYS_SOUNDCARD_H | |
154 tmp=oss_card_manager_init(manager,index); | |
155 index+=tmp; | |
156 if (index>=MAX_SND_CARDS) return; | |
157 #endif | |
158 #ifdef __ALSA_ENABLED__ | |
159 tmp=alsa_card_manager_init(manager,index); | |
160 index+=tmp; | |
161 if (index>=MAX_SND_CARDS) return; | |
162 #endif | |
163 #ifdef __JACK_ENABLED__ | |
164 tmp=jack_card_manager_init(manager,index); | |
165 index+=tmp; | |
166 if (index>=MAX_SND_CARDS) return; | |
167 #endif | |
168 #ifdef HAVE_SYS_AUDIO_H | |
169 tmp=sys_audio_manager_init(manager,index); | |
170 index+=tmp; | |
171 #endif | |
172 } | |
173 | |
174 | |
175 | |
176 | |
177 | |
178 SndCard * snd_card_manager_get_card(SndCardManager *manager,int index) | |
179 { | |
180 g_return_val_if_fail(index>=0,NULL); | |
181 g_return_val_if_fail(index<MAX_SND_CARDS,NULL); | |
182 if (index>MAX_SND_CARDS) return NULL; | |
183 return manager->cards[index]; | |
184 } | |
185 | |
186 SndCard * snd_card_manager_get_card_with_string(SndCardManager *manager,const char *cardname,int *index) | |
187 { | |
188 int i; | |
189 for (i=0;i<MAX_SND_CARDS;i++){ | |
190 gchar *card_name; | |
191 if (manager->cards[i]==NULL) continue; | |
192 card_name=manager->cards[i]->card_name; | |
193 if (card_name==NULL) continue; | |
194 if (strcmp(card_name,cardname)==0){ | |
195 *index=i; | |
196 return manager->cards[i]; | |
197 } | |
198 } | |
199 g_warning("No card %s found.",cardname); | |
200 return NULL; | |
201 } | |
202 | |
203 SndCardManager _snd_card_manager; | |
204 SndCardManager *snd_card_manager=&_snd_card_manager; |