Fri, 02 Dec 2005 07:30:49 +0000
[gaim-migrate @ 14598]
sadrul and I noticed that using space stopped bringing the statusbox menu up
recently, this fixes that. sadrul had used the "clicked" signal, I feel
"toggled" is probably better, but I really don't know that it matters. Also I
commented out the button-{press,release}-event signal handlers/connections
since the menu works without them now. If there is a reason we still need them
put them back.
| 12024 | 1 | /** |
|
12050
a7d5a2430722
[gaim-migrate @ 14345]
Mark Doliner <markdoliner@pidgin.im>
parents:
12034
diff
changeset
|
2 | * @file media.c Voice and Video API |
| 12024 | 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 | ||
|
12034
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
26 | #include "internal.h" |
|
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
27 | |
| 12024 | 28 | #ifdef HAVE_VV |
| 29 | ||
| 30 | #include "media.h" | |
| 31 | #include "mediastream.h" | |
|
12215
aefc01185eda
[gaim-migrate @ 14517]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12050
diff
changeset
|
32 | #ifdef HAVE_ILBC |
| 12024 | 33 | #include "msilbcdec.h" |
|
12215
aefc01185eda
[gaim-migrate @ 14517]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12050
diff
changeset
|
34 | #endif |
| 12024 | 35 | |
| 36 | ||
| 37 | /* msrtpsend.o and msrtprecv.o aren't used within the core, so | |
| 38 | * the linker chooses not to link them. I want plugins to be able | |
| 39 | * to depend on them, so I reference symbols from them here. */ | |
| 40 | static void * dummy1 = ms_rtp_send_new; | |
| 41 | static void * dummy2 = ms_rtp_recv_new; | |
| 42 | ||
| 43 | struct _GaimVoiceChat { | |
| 44 | GaimConnection *gc; | |
| 45 | char *name; | |
| 46 | ||
| 47 | GaimMediaState state; | |
| 48 | ||
| 49 | void *proto_data; | |
| 50 | void *ui_data; | |
| 51 | ||
| 52 | MSFilter *speaker; | |
| 53 | MSFilter *microphone; | |
| 54 | MSSync *timer; | |
| 55 | }; | |
| 56 | ||
| 57 | static GaimMediaUiOps *media_ui_ops = NULL; | |
| 58 | ||
| 59 | void gaim_media_init() | |
| 60 | { | |
| 61 | ms_init(); | |
|
12215
aefc01185eda
[gaim-migrate @ 14517]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12050
diff
changeset
|
62 | #ifdef HAVE_ILBC |
| 12024 | 63 | ms_ilbc_codec_init(); |
|
12215
aefc01185eda
[gaim-migrate @ 14517]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12050
diff
changeset
|
64 | #endif |
| 12024 | 65 | ms_speex_codec_init(); |
| 66 | ortp_init(); | |
| 67 | } | |
| 68 | ||
| 69 | GaimVoiceChat *gaim_voice_chat_new(GaimConnection *gc, const char *name) | |
| 70 | { | |
| 71 | GaimVoiceChat *vc = g_new0(GaimVoiceChat, 1); | |
| 72 | SndCard *card; | |
| 73 | ||
| 74 | vc->gc = gc; | |
| 75 | vc->name = g_strdup(name); | |
| 76 | ||
| 77 | card = snd_card_manager_get_card(snd_card_manager,0); | |
| 78 | vc->speaker = snd_card_create_write_filter(card); | |
| 79 | vc->microphone = snd_card_create_read_filter(card); | |
| 80 | vc->timer = ms_timer_new(); | |
| 81 | ms_sync_attach(vc->timer, vc->microphone); | |
| 82 | if (media_ui_ops) | |
| 83 | media_ui_ops->new_voice_chat(vc); | |
| 84 | return vc; | |
| 85 | } | |
| 86 | ||
| 87 | ||
| 88 | ||
| 89 | void gaim_voice_chat_destroy(GaimVoiceChat *vc) | |
| 90 | { | |
| 91 | if (media_ui_ops) | |
| 92 | media_ui_ops->destroy(vc); | |
| 93 | g_free(vc); | |
| 94 | } | |
| 95 | ||
| 96 | const char *gaim_voice_chat_get_name(GaimVoiceChat *vc) | |
| 97 | { | |
| 98 | return vc->name; | |
| 99 | } | |
| 100 | ||
| 101 | void gaim_voice_chat_set_name(GaimVoiceChat *vc, const char *name) | |
| 102 | { | |
| 103 | g_free(vc->name); | |
| 104 | vc->name = g_strdup(name); | |
| 105 | } | |
| 106 | ||
| 107 | GaimConnection *gaim_voice_chat_get_connection(GaimVoiceChat *vc) | |
| 108 | { | |
| 109 | return vc->gc; | |
| 110 | } | |
| 111 | ||
| 112 | void *gaim_voice_chat_get_ui_data(GaimVoiceChat *vc) | |
| 113 | { | |
| 114 | return vc->ui_data; | |
| 115 | } | |
| 116 | ||
| 117 | void gaim_voice_chat_set_ui_data(GaimVoiceChat *vc, void *data) | |
| 118 | { | |
| 119 | vc->ui_data = data; | |
| 120 | } | |
| 121 | ||
| 122 | void *gaim_voice_chat_get_proto_data(GaimVoiceChat *vc) | |
| 123 | { | |
| 124 | return vc->proto_data; | |
| 125 | } | |
| 126 | ||
| 127 | void gaim_voice_chat_set_proto_data(GaimVoiceChat *vc, void *data) | |
| 128 | { | |
| 129 | vc->proto_data = data; | |
| 130 | } | |
| 131 | ||
| 132 | void gaim_media_set_ui_ops(GaimMediaUiOps *ops) | |
| 133 | { | |
| 134 | media_ui_ops = ops; | |
| 135 | } | |
| 136 | ||
| 137 | GaimMediaUiOps *gaim_media_get_ui_ops(void) | |
| 138 | { | |
| 139 | return media_ui_ops; | |
| 140 | } | |
| 141 | ||
| 142 | ||
| 143 | GaimMediaState gaim_voice_chat_get_state(GaimVoiceChat *vc) | |
| 144 | { | |
| 145 | return vc->state; | |
| 146 | } | |
| 147 | ||
| 148 | void gaim_voice_chat_accept(GaimVoiceChat *vc) | |
| 149 | { | |
| 150 | GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
| 151 | GaimPluginProtocolInfo *prpl_info = NULL; | |
| 152 | ||
| 153 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 154 | ||
| 155 | if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->accept) | |
| 156 | return; | |
| 157 | prpl_info->media_prpl_ops->accept(vc); | |
| 158 | } | |
| 159 | ||
| 160 | void gaim_voice_chat_reject(GaimVoiceChat *vc) | |
| 161 | { | |
| 162 | GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
| 163 | GaimPluginProtocolInfo *prpl_info = NULL; | |
| 164 | ||
| 165 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 166 | ||
| 167 | if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->reject) | |
| 168 | return; | |
| 169 | prpl_info->media_prpl_ops->reject(vc); | |
| 170 | } | |
| 171 | ||
| 172 | ||
| 173 | void gaim_voice_chat_terminate(GaimVoiceChat *vc) | |
| 174 | { | |
| 175 | GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
| 176 | GaimPluginProtocolInfo *prpl_info = NULL; | |
| 177 | ||
| 178 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 179 | ||
| 180 | if (!prpl_info->media_prpl_ops || !prpl_info->media_prpl_ops->terminate) | |
| 181 | return; | |
| 182 | prpl_info->media_prpl_ops->terminate(vc); | |
| 183 | } | |
| 184 | ||
| 185 | ||
| 186 | void gaim_voice_chat_set_state(GaimVoiceChat *vc, GaimMediaState state) | |
| 187 | { | |
| 188 | vc->state = state; | |
|
12034
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
189 | printf("State: %d\n",state); |
| 12024 | 190 | if (media_ui_ops) |
| 191 | media_ui_ops->state_change(vc, state); | |
| 192 | } | |
| 193 | ||
| 194 | void gaim_voice_chat_get_filters(GaimVoiceChat *vc, MSFilter **microphone, MSFilter **speaker) | |
| 195 | { | |
| 196 | if (microphone) *microphone = vc->microphone; | |
| 197 | if (speaker) *speaker = vc->speaker; | |
| 198 | } | |
| 199 | ||
| 200 | MSSync *gaim_voice_chat_get_timer(GaimVoiceChat *vc) | |
| 201 | { | |
| 202 | return vc->timer; | |
| 203 | } | |
| 204 | ||
|
12034
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
205 | void gaim_voice_chat_start_streams(GaimVoiceChat *vc) |
| 12024 | 206 | { |
| 207 | GaimConnection *gc = gaim_voice_chat_get_connection(vc); | |
| 208 | GaimPluginProtocolInfo *prpl_info = NULL; | |
| 209 | ||
| 210 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 211 | ||
| 212 | if (prpl_info->media_prpl_ops && prpl_info->media_prpl_ops->init_filters) | |
| 213 | prpl_info->media_prpl_ops->init_filters(vc); | |
| 214 | ||
| 215 | ms_start(vc->timer); | |
| 216 | } | |
| 217 | ||
| 218 | #endif /* HAVE_VV */ |