Thu, 05 Jan 2006 00:39:52 +0000
[gaim-migrate @ 15070]
Fix this off-by-one bug that resulted from my removal of GAIM_STATUS_UNSET:
(18:26:53) NSA_: go into the saved status editor and choose some status to edit. then for "Status:" select one and save the status. it will select the value for the index-1 in that select box
| 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" | |
| 32 | ||
| 33 | ||
| 34 | /* msrtpsend.o and msrtprecv.o aren't used within the core, so | |
| 35 | * the linker chooses not to link them. I want plugins to be able | |
| 36 | * to depend on them, so I reference symbols from them here. */ | |
| 37 | static void * dummy1 = ms_rtp_send_new; | |
| 38 | static void * dummy2 = ms_rtp_recv_new; | |
| 39 | ||
| 40 | struct _GaimVoiceChat { | |
| 41 | GaimConnection *gc; | |
| 42 | char *name; | |
| 43 | ||
| 44 | GaimMediaState state; | |
| 45 | ||
| 46 | void *proto_data; | |
| 47 | void *ui_data; | |
| 48 | ||
| 49 | MSFilter *speaker; | |
| 50 | MSFilter *microphone; | |
| 51 | MSSync *timer; | |
| 52 | }; | |
| 53 | ||
| 54 | static GaimMediaUiOps *media_ui_ops = NULL; | |
| 55 | ||
| 56 | void gaim_media_init() | |
| 57 | { | |
| 58 | ms_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; | |
|
12034
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
183 | printf("State: %d\n",state); |
| 12024 | 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 | ||
|
12034
e40d6191f530
[gaim-migrate @ 14327]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12024
diff
changeset
|
199 | void gaim_voice_chat_start_streams(GaimVoiceChat *vc) |
| 12024 | 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 */ |