audio: depurple candidate
[siplcs.git] / src / purple / purple-media.c
blobb123193163e473dd5be5160e077668dabe5e0f26
1 /**
2 * @file purple-media.c
4 * pidgin-sipe
6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "glib.h"
25 #include "sipe-media.h"
26 #include "media.h"
28 PurpleMediaSessionType sipe_media_to_purple(SipeMediaType type)
30 switch (type) {
31 case SIPE_MEDIA_AUDIO: return PURPLE_MEDIA_AUDIO;
32 case SIPE_MEDIA_VIDEO: return PURPLE_MEDIA_VIDEO;
33 default: return PURPLE_MEDIA_NONE;
37 /*SipeMediaType purple_media_to_sipe(PurpleMediaSessionType type)
39 switch (type) {
40 case PURPLE_MEDIA_AUDIO: return SIPE_MEDIA_AUDIO;
41 case PURPLE_MEDIA_VIDEO: return SIPE_MEDIA_VIDEO;
42 default: return SIPE_MEDIA_AUDIO;
44 }*/
46 static PurpleMediaCandidateType
47 sipe_candidate_type_to_purple(SipeCandidateType type)
49 switch (type) {
50 case SIPE_CANDIDATE_TYPE_HOST: return PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
51 case SIPE_CANDIDATE_TYPE_RELAY: return PURPLE_MEDIA_CANDIDATE_TYPE_RELAY;
52 case SIPE_CANDIDATE_TYPE_SRFLX: return PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX;
53 default: return PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
57 static PurpleMediaNetworkProtocol
58 sipe_network_protocol_to_purple(SipeNetworkProtocol proto)
60 switch (proto) {
61 case SIPE_NETWORK_PROTOCOL_TCP: return PURPLE_MEDIA_NETWORK_PROTOCOL_TCP;
62 case SIPE_NETWORK_PROTOCOL_UDP: return PURPLE_MEDIA_NETWORK_PROTOCOL_UDP;
63 default: return PURPLE_MEDIA_NETWORK_PROTOCOL_TCP;
68 sipe_codec *
69 sipe_backend_codec_new(int id, const char *name, SipeMediaType type, guint clock_rate)
71 return (sipe_codec *)purple_media_codec_new(id, name,
72 sipe_media_to_purple(type), clock_rate);
75 void
76 sipe_backend_codec_free(sipe_codec *codec)
78 g_object_unref(codec);
81 int
82 sipe_backend_codec_get_id(sipe_codec *codec)
84 return purple_media_codec_get_id((PurpleMediaCodec *)codec);
87 gchar *
88 sipe_backend_codec_get_name(sipe_codec *codec)
90 return purple_media_codec_get_encoding_name((PurpleMediaCodec *)codec);
93 guint
94 sipe_backend_codec_get_clock_rate(sipe_codec *codec)
96 return purple_media_codec_get_clock_rate((PurpleMediaCodec *)codec);
99 GList *
100 sipe_backend_codec_get_optional_parameters(sipe_codec *codec)
102 return purple_media_codec_get_optional_parameters((PurpleMediaCodec *)codec);
105 gboolean
106 sipe_backend_set_remote_codecs(struct _sipe_media_call* call, gchar* participant)
108 PurpleMedia *media = call->media;
109 GList *codecs = call->remote_codecs;
111 return purple_media_set_remote_codecs(media, "sipe-voice", participant, codecs);
114 GList*
115 sipe_backend_get_local_codecs(struct _sipe_media_call* call)
117 return purple_media_get_codecs(call->media, "sipe-voice");
120 sipe_candidate *
121 sipe_backend_candidate_new(const gchar *foundation, SipeComponentType component,
122 SipeCandidateType type, SipeNetworkProtocol proto,
123 const gchar *ip, guint port)
125 return (sipe_candidate *)purple_media_candidate_new(
126 foundation,
127 component,
128 sipe_candidate_type_to_purple(type),
129 sipe_network_protocol_to_purple(proto),
131 port);
134 void
135 sipe_backend_candidate_free(sipe_candidate *codec)
137 g_object_unref(codec);
140 gchar *
141 sipe_backend_candidate_get_username(sipe_candidate *candidate)
143 return purple_media_candidate_get_username((PurpleMediaCandidate*)candidate);
146 gchar *
147 sipe_backend_candidate_get_password(sipe_candidate *candidate)
149 return purple_media_candidate_get_password((PurpleMediaCandidate*)candidate);
152 gchar *
153 sipe_backend_candidate_get_foundation(sipe_candidate *candidate)
155 return purple_media_candidate_get_foundation((PurpleMediaCandidate*)candidate);
158 gchar *
159 sipe_backend_candidate_get_ip(sipe_candidate *candidate)
161 return purple_media_candidate_get_ip((PurpleMediaCandidate*)candidate);
164 guint
165 sipe_backend_candidate_get_port(sipe_candidate *candidate)
167 return purple_media_candidate_get_port((PurpleMediaCandidate*)candidate);
170 guint32
171 sipe_backend_candidate_get_priority(sipe_candidate *candidate)
173 return purple_media_candidate_get_priority((PurpleMediaCandidate*)candidate);
176 SipeComponentType
177 sipe_backend_candidate_get_component_type(sipe_candidate *candidate)
179 return purple_media_candidate_get_component_id((PurpleMediaCandidate*)candidate);
182 SipeCandidateType
183 sipe_backend_candidate_get_type(sipe_candidate *candidate)
185 return purple_media_candidate_get_candidate_type((PurpleMediaCandidate*)candidate);
188 SipeNetworkProtocol
189 sipe_backend_candidate_get_protocol(sipe_candidate *candidate)
191 return purple_media_candidate_get_protocol((PurpleMediaCandidate*)candidate);
194 void
195 sipe_backend_candidate_set_username_and_pwd(sipe_candidate *candidate,
196 const gchar *username,
197 const gchar *password)
199 g_object_set(candidate, "username", username, "password", password, NULL);
203 Local Variables:
204 mode: c
205 c-file-style: "bsd"
206 indent-tabs-mode: t
207 tab-width: 8
208 End: