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
25 #include "sipe-media.h"
28 PurpleMediaSessionType
sipe_media_to_purple(SipeMediaType 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)
40 case PURPLE_MEDIA_AUDIO: return SIPE_MEDIA_AUDIO;
41 case PURPLE_MEDIA_VIDEO: return SIPE_MEDIA_VIDEO;
42 default: return SIPE_MEDIA_AUDIO;
46 static PurpleMediaCandidateType
47 sipe_candidate_type_to_purple(SipeCandidateType 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
)
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
;
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
);
76 sipe_backend_codec_free(sipe_codec
*codec
)
78 g_object_unref(codec
);
82 sipe_backend_codec_get_id(sipe_codec
*codec
)
84 return purple_media_codec_get_id((PurpleMediaCodec
*)codec
);
88 sipe_backend_codec_get_name(sipe_codec
*codec
)
90 return purple_media_codec_get_encoding_name((PurpleMediaCodec
*)codec
);
94 sipe_backend_codec_get_clock_rate(sipe_codec
*codec
)
96 return purple_media_codec_get_clock_rate((PurpleMediaCodec
*)codec
);
100 sipe_backend_codec_get_optional_parameters(sipe_codec
*codec
)
102 return purple_media_codec_get_optional_parameters((PurpleMediaCodec
*)codec
);
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
);
115 sipe_backend_get_local_codecs(struct _sipe_media_call
* call
)
117 return purple_media_get_codecs(call
->media
, "sipe-voice");
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(
128 sipe_candidate_type_to_purple(type
),
129 sipe_network_protocol_to_purple(proto
),
135 sipe_backend_candidate_free(sipe_candidate
*codec
)
137 g_object_unref(codec
);
141 sipe_backend_candidate_get_username(sipe_candidate
*candidate
)
143 return purple_media_candidate_get_username((PurpleMediaCandidate
*)candidate
);
147 sipe_backend_candidate_get_password(sipe_candidate
*candidate
)
149 return purple_media_candidate_get_password((PurpleMediaCandidate
*)candidate
);
153 sipe_backend_candidate_get_foundation(sipe_candidate
*candidate
)
155 return purple_media_candidate_get_foundation((PurpleMediaCandidate
*)candidate
);
159 sipe_backend_candidate_get_ip(sipe_candidate
*candidate
)
161 return purple_media_candidate_get_ip((PurpleMediaCandidate
*)candidate
);
165 sipe_backend_candidate_get_port(sipe_candidate
*candidate
)
167 return purple_media_candidate_get_port((PurpleMediaCandidate
*)candidate
);
171 sipe_backend_candidate_get_priority(sipe_candidate
*candidate
)
173 return purple_media_candidate_get_priority((PurpleMediaCandidate
*)candidate
);
177 sipe_backend_candidate_get_component_type(sipe_candidate
*candidate
)
179 return purple_media_candidate_get_component_id((PurpleMediaCandidate
*)candidate
);
183 sipe_backend_candidate_get_type(sipe_candidate
*candidate
)
185 return purple_media_candidate_get_candidate_type((PurpleMediaCandidate
*)candidate
);
189 sipe_backend_candidate_get_protocol(sipe_candidate
*candidate
)
191 return purple_media_candidate_get_protocol((PurpleMediaCandidate
*)candidate
);
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
);