Fix a crash when remote users have certain characters in their
[pidgin-git.git] / libpurple / media / candidate.h
blob1dfa0fd05e9081d50c7970c646f35a461aee828a
1 /**
2 * @file candidate.h Candidate for Media API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef _PURPLE_MEDIA_CANDIDATE_H_
28 #define _PURPLE_MEDIA_CANDIDATE_H_
30 #include "enum-types.h"
32 #include <glib-object.h>
34 G_BEGIN_DECLS
36 #define PURPLE_TYPE_MEDIA_CANDIDATE (purple_media_candidate_get_type())
37 #define PURPLE_IS_MEDIA_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_CANDIDATE))
38 #define PURPLE_IS_MEDIA_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_CANDIDATE))
39 #define PURPLE_MEDIA_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
40 #define PURPLE_MEDIA_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
41 #define PURPLE_MEDIA_CANDIDATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_CANDIDATE, PurpleMediaCandidate))
43 /** An opaque structure representing a network candidate (IP Address and port pair). */
44 typedef struct _PurpleMediaCandidate PurpleMediaCandidate;
46 /**
47 * Gets the type of the media candidate structure.
49 * @return The media canditate's GType
51 * @since 2.6.0
53 GType purple_media_candidate_get_type(void);
55 /**
56 * Creates a PurpleMediaCandidate instance.
58 * @param foundation The foundation of the candidate.
59 * @param component_id The component this candidate is for.
60 * @param type The type of candidate.
61 * @param proto The protocol this component is for.
62 * @param ip The IP address of this component.
63 * @param port The network port.
65 * @return The newly created PurpleMediaCandidate instance.
67 * @since 2.6.0
69 PurpleMediaCandidate *purple_media_candidate_new(
70 const gchar *foundation, guint component_id,
71 PurpleMediaCandidateType type,
72 PurpleMediaNetworkProtocol proto,
73 const gchar *ip, guint port);
75 /**
76 * Copies a PurpleMediaCandidate.
78 * @param candidate The candidate to copy.
80 * @return The copy of the PurpleMediaCandidate.
82 * @since 2.7.0
84 PurpleMediaCandidate *purple_media_candidate_copy(
85 PurpleMediaCandidate *candidate);
87 /**
88 * Copies a GList of PurpleMediaCandidate and its contents.
90 * @param candidates The list of candidates to be copied.
92 * @return The copy of the GList.
94 * @since 2.6.0
96 GList *purple_media_candidate_list_copy(GList *candidates);
98 /**
99 * Frees a GList of PurpleMediaCandidate and its contents.
101 * @param candidates The list of candidates to be freed.
103 * @since 2.6.0
105 void purple_media_candidate_list_free(GList *candidates);
108 * Gets the foundation (identifier) from the candidate.
110 * @param candidate The candidate to get the foundation from.
112 * @return The foundation.
114 * @since 2.6.0
116 gchar *purple_media_candidate_get_foundation(PurpleMediaCandidate *candidate);
119 * Gets the component id (rtp or rtcp)
121 * @param candidate The candidate to get the compnent id from.
123 * @return The component id.
125 * @since 2.6.0
127 guint purple_media_candidate_get_component_id(PurpleMediaCandidate *candidate);
130 * Gets the IP address.
132 * @param candidate The candidate to get the IP address from.
134 * @return The IP address.
136 * @since 2.6.0
138 gchar *purple_media_candidate_get_ip(PurpleMediaCandidate *candidate);
141 * Gets the port.
143 * @param candidate The candidate to get the port from.
145 * @return The port.
147 * @since 2.6.0
149 guint16 purple_media_candidate_get_port(PurpleMediaCandidate *candidate);
152 * Gets the base (internal) IP address.
154 * This can be NULL.
156 * @param candidate The candidate to get the base IP address from.
158 * @return The base IP address.
160 * @since 2.6.0
162 gchar *purple_media_candidate_get_base_ip(PurpleMediaCandidate *candidate);
165 * Gets the base (internal) port.
167 * Invalid if the base IP is NULL.
169 * @param candidate The candidate to get the base port.
171 * @return The base port.
173 * @since 2.6.0
175 guint16 purple_media_candidate_get_base_port(PurpleMediaCandidate *candidate);
178 * Gets the protocol (TCP or UDP).
180 * @param candidate The candidate to get the protocol from.
182 * @return The protocol.
184 * @since 2.6.0
186 PurpleMediaNetworkProtocol purple_media_candidate_get_protocol(
187 PurpleMediaCandidate *candidate);
190 * Gets the priority.
192 * @param candidate The candidate to get the priority from.
194 * @return The priority.
196 * @since 2.6.0
198 guint32 purple_media_candidate_get_priority(PurpleMediaCandidate *candidate);
201 * Gets the candidate type.
203 * @param candidate The candidate to get the candidate type from.
205 * @return The candidate type.
207 * @since 2.6.0
209 PurpleMediaCandidateType purple_media_candidate_get_candidate_type(
210 PurpleMediaCandidate *candidate);
213 * Gets the username.
215 * This can be NULL. It depends on the transmission type.
217 * @param The candidate to get the username from.
219 * @return The username.
221 * @since 2.6.0
223 gchar *purple_media_candidate_get_username(PurpleMediaCandidate *candidate);
226 * Gets the password.
228 * This can be NULL. It depends on the transmission type.
230 * @param The candidate to get the password from.
232 * @return The password.
234 * @since 2.6.0
236 gchar *purple_media_candidate_get_password(PurpleMediaCandidate *candidate);
239 * Gets the TTL.
241 * @param The candidate to get the TTL from.
243 * @return The TTL.
245 * @since 2.6.0
247 guint purple_media_candidate_get_ttl(PurpleMediaCandidate *candidate);
249 G_END_DECLS
251 #endif /* _PURPLE_MEDIA_CANDIDATE_H_ */