Mercurial > pidgin
comparison src/media.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 | bad5f83e7f22 |
comparison
equal
deleted
inserted
replaced
12023:80faf1ca5280 | 12024:e67993da8a22 |
---|---|
1 /** | |
2 * @file media.h Voice and Video API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 | |
26 #ifdef HAVE_VV | |
27 | |
28 #include "media.h" | |
29 #include "mediastream.h" | |
30 #include "msilbcdec.h" | |
31 | |
32 | |
33 /* msrtpsend.o and msrtprecv.o aren't used within the core, so | |
34 * the linker chooses not to link them. I want plugins to be able | |
35 * to depend on them, so I reference symbols from them here. */ | |
36 static void * dummy1 = ms_rtp_send_new; | |
37 static void * dummy2 = ms_rtp_recv_new; | |
38 | |
39 struct _GaimVoiceChat { | |
40 GaimConnection *gc; | |
41 char *name; | |
42 | |
43 GaimMediaState state; | |
44 | |
45 void *proto_data; | |
46 void *ui_data; | |
47 | |
48 MSFilter *speaker; | |
49 MSFilter *microphone; | |
50 MSSync *timer; | |
51 }; | |
52 | |
53 static GaimMediaUiOps *media_ui_ops = NULL; | |
54 | |
55 void gaim_media_init() | |
56 { | |
57 ms_init(); | |
58 ms_ilbc_codec_init(); | |
59 ms_speex_codec_init(); | |
60 ortp_init(); | |
61 } | |
62 | |
63 GaimVoiceChat *gaim_voice_chat_new(GaimConnection *gc, const char *name) | |
64 { | |
65 GaimVoiceChat *vc = g_new0(GaimVoiceChat, 1); | |
66 SndCard *card; | |
67 | |
68 vc->gc = gc; | |
69 vc->name = g_strdup(name); | |
70 | |
71 card = snd_card_manager_get_card(snd_card_manager,0); | |
72 vc->speaker = snd_card_create_write_filter(card); | |
73 vc->microphone = snd_card_create_read_filter(card); | |
74 vc->timer = ms_timer_new(); | |
75 ms_sync_attach(vc->timer, vc->microphone); | |
76 if (media_ui_ops) | |
77 media_ui_ops->new_voice_chat(vc); | |
78 return vc; | |
79 } | |
80 | |
81 | |
82 | |
83 void gaim_voice_chat_destroy(GaimVoiceChat *vc) | |
84 { | |
85 if (media_ui_ops) | |
86 media_ui_ops->destroy(vc); | |
87 g_free(vc); | |
88 } | |
89 | |
90 const char *gaim_voice_chat_get_name(GaimVoiceChat *vc) | |
91 { | |
92 return vc->name; | |
93 } | |
94 | |
95 void gaim_voice_chat_set_name(GaimVoiceChat *vc, const char *name) | |
96 { | |
97 g_free(vc->name); | |
98 vc->name = g_strdup(name); | |
99 } | |
100 | |
101 GaimConnection *gaim_voice_chat_get_connection(GaimVoiceChat *vc) | |
102 { | |
103 return vc->gc; | |
104 } | |
105 | |
106 void *gaim_voice_chat_get_ui_data(GaimVoiceChat *vc) | |
107 { | |
108 return vc->ui_data; | |
109 } | |
110 | |
111 void gaim_voice_chat_set_ui_data(GaimVoiceChat *vc, void *data) | |
112 { | |
113 vc->ui_data = data; | |
114 } | |
115 | |
116 void *gaim_voice_chat_get_proto_data(GaimVoiceChat *vc) | |
117 { | |
118 return vc->proto_data; | |
119 } | |
120 | |
121 void gaim_voice_chat_set_proto_data(GaimVoiceChat *vc, void *data) | |
122 { | |
123 vc->proto_data = data; | |
124 } | |
125 | |
126 void gaim_media_set_ui_ops(GaimMediaUiOps *ops) | |
127 { | |
128 media_ui_ops = ops; | |
129 } | |
130 | |
131 GaimMediaUiOps *gaim_media_get_ui_ops(void) | |
132 { | |
133 return media_ui_ops; | |
134 } | |
135 | |
136 | |
137 GaimMediaState gaim_voice_chat_get_state(GaimVoiceChat *vc) | |
138 { | |
139 return vc->state; | |
140 } | |
141 | |
142 void gaim_voice_chat_accept(GaimVoiceChat *vc) | |
143 { | |
144 GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
145 GaimPluginProtocolInfo *prpl_info = NULL; | |
146 | |
147 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
148 | |
149 if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->accept) | |
150 return; | |
151 prpl_info->media_prpl_ops->accept(vc); | |
152 } | |
153 | |
154 void gaim_voice_chat_reject(GaimVoiceChat *vc) | |
155 { | |
156 GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
157 GaimPluginProtocolInfo *prpl_info = NULL; | |
158 | |
159 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
160 | |
161 if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->reject) | |
162 return; | |
163 prpl_info->media_prpl_ops->reject(vc); | |
164 } | |
165 | |
166 | |
167 void gaim_voice_chat_terminate(GaimVoiceChat *vc) | |
168 { | |
169 GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
170 GaimPluginProtocolInfo *prpl_info = NULL; | |
171 | |
172 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
173 | |
174 if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->terminate) | |
175 return; | |
176 prpl_info->media_prpl_ops->terminate(vc); | |
177 } | |
178 | |
179 | |
180 void gaim_voice_chat_set_state(GaimVoiceChat *vc, GaimMediaState state) | |
181 { | |
182 vc->state = state; | |
183 printf("State: %d\n",vc); | |
184 if (media_ui_ops) | |
185 media_ui_ops->state_change(vc, state); | |
186 } | |
187 | |
188 void gaim_voice_chat_get_filters(GaimVoiceChat *vc, MSFilter **microphone, MSFilter **speaker) | |
189 { | |
190 if (microphone) *microphone = vc->microphone; | |
191 if (speaker) *speaker = vc->speaker; | |
192 } | |
193 | |
194 MSSync *gaim_voice_chat_get_timer(GaimVoiceChat *vc) | |
195 { | |
196 return vc->timer; | |
197 } | |
198 | |
199 void *gaim_voice_chat_start_streams(GaimVoiceChat *vc) | |
200 { | |
201 GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
202 GaimPluginProtocolInfo *prpl_info = NULL; | |
203 | |
204 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
205 | |
206 if (prpl_info->media_prpl_ops && prpl_info->media_prpl_ops->init_filters) | |
207 prpl_info->media_prpl_ops->init_filters(vc); | |
208 | |
209 ms_start(vc->timer); | |
210 } | |
211 | |
212 #endif /* HAVE_VV */ |