Fix an incorrect call to soup_message_set_request.
[pidgin-git.git] / libpurple / media / backend-iface.c
blobaebece6371dad43027cd1053296f7ad8232cd1f0
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include "internal.h"
24 #include "backend-iface.h"
26 enum {
27 S_ERROR,
28 CANDIDATES_PREPARED,
29 CODECS_CHANGED,
30 NEW_CANDIDATE,
31 ACTIVE_CANDIDATE_PAIR,
32 LAST_SIGNAL
35 static guint purple_media_backend_signals[LAST_SIGNAL] = {0};
37 static void
38 purple_media_backend_base_init(gpointer iface)
40 static gboolean is_initialized = FALSE;
42 if (is_initialized)
43 return;
45 g_object_interface_install_property(iface,
46 g_param_spec_string("conference-type",
47 "Conference Type",
48 "The type of conference that this backend "
49 "has been created to provide.",
50 NULL,
51 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
52 G_PARAM_STATIC_STRINGS));
53 g_object_interface_install_property(iface,
54 #ifdef USE_VV
55 g_param_spec_object(
56 #else
57 g_param_spec_pointer(
58 #endif
59 "media", "Purple Media",
60 "The media object that this backend is bound to.",
61 #ifdef USE_VV
62 PURPLE_TYPE_MEDIA,
63 #endif
64 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
65 G_PARAM_STATIC_STRINGS));
66 purple_media_backend_signals[S_ERROR] =
67 g_signal_new("error", G_TYPE_FROM_CLASS(iface),
68 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
69 G_TYPE_NONE, 1, G_TYPE_STRING);
70 purple_media_backend_signals[CANDIDATES_PREPARED] =
71 g_signal_new("candidates-prepared",
72 G_TYPE_FROM_CLASS(iface),
73 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
74 G_TYPE_NONE, 2, G_TYPE_STRING,
75 G_TYPE_STRING);
76 purple_media_backend_signals[CODECS_CHANGED] =
77 g_signal_new("codecs-changed",
78 G_TYPE_FROM_CLASS(iface),
79 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
80 G_TYPE_NONE, 1, G_TYPE_STRING);
81 purple_media_backend_signals[NEW_CANDIDATE] =
82 g_signal_new("new-candidate",
83 G_TYPE_FROM_CLASS(iface),
84 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
85 G_TYPE_NONE, 3, G_TYPE_POINTER,
86 G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE);
87 purple_media_backend_signals[ACTIVE_CANDIDATE_PAIR] =
88 g_signal_new("active-candidate-pair",
89 G_TYPE_FROM_CLASS(iface),
90 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
91 G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
92 PURPLE_TYPE_MEDIA_CANDIDATE,
93 PURPLE_TYPE_MEDIA_CANDIDATE);
95 is_initialized = TRUE;
98 GType
99 purple_media_backend_get_type(void)
101 static GType iface_type = 0;
102 if (iface_type == 0) {
103 static const GTypeInfo info = {
104 sizeof(PurpleMediaBackendInterface),
105 purple_media_backend_base_init,
106 NULL,
107 NULL,
108 NULL,
109 NULL,
112 NULL,
113 NULL
116 iface_type = g_type_register_static (G_TYPE_INTERFACE,
117 "PurpleMediaBackend", &info, 0);
120 return iface_type;
123 gboolean
124 purple_media_backend_add_stream(PurpleMediaBackend *self,
125 const gchar *sess_id, const gchar *who,
126 PurpleMediaSessionType type, gboolean initiator,
127 const gchar *transmitter,
128 guint num_params, GParameter *params)
130 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
131 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_stream(self,
132 sess_id, who, type, initiator, transmitter,
133 num_params, params);
136 void
137 purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
138 const gchar *sess_id, const gchar *participant,
139 GList *remote_candidates)
141 g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
142 PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->add_remote_candidates(self,
143 sess_id, participant, remote_candidates);
146 gboolean
147 purple_media_backend_codecs_ready(PurpleMediaBackend *self,
148 const gchar *sess_id)
150 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
151 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->codecs_ready(self,
152 sess_id);
155 GList *
156 purple_media_backend_get_codecs(PurpleMediaBackend *self,
157 const gchar *sess_id)
159 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
160 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_codecs(self,
161 sess_id);
164 GList *
165 purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
166 const gchar *sess_id, const gchar *participant)
168 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL);
169 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->
170 get_local_candidates(self,
171 sess_id, participant);
174 gboolean
175 purple_media_backend_set_remote_codecs(PurpleMediaBackend *self,
176 const gchar *sess_id, const gchar *participant,
177 GList *codecs)
179 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
180 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_remote_codecs(
181 self, sess_id, participant, codecs);
184 gboolean
185 purple_media_backend_set_send_codec(PurpleMediaBackend *self,
186 const gchar *sess_id, PurpleMediaCodec *codec)
188 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
189 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_send_codec(self,
190 sess_id, codec);
193 gboolean
194 purple_media_backend_set_encryption_parameters(PurpleMediaBackend *self,
195 const gchar *sess_id, const gchar *cipher,
196 const gchar *auth, const gchar *key, gsize key_len)
198 PurpleMediaBackendInterface *backend_iface;
200 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
201 backend_iface = PURPLE_MEDIA_BACKEND_GET_INTERFACE(self);
202 g_return_val_if_fail(backend_iface->set_encryption_parameters, FALSE);
203 return backend_iface->set_encryption_parameters(self,
204 sess_id, cipher, auth, key, key_len);
207 gboolean
208 purple_media_backend_set_decryption_parameters(PurpleMediaBackend *self,
209 const gchar *sess_id, const gchar *participant,
210 const gchar *cipher, const gchar *auth,
211 const gchar *key, gsize key_len)
213 PurpleMediaBackendInterface *backend_iface;
215 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
216 backend_iface = PURPLE_MEDIA_BACKEND_GET_INTERFACE(self);
217 g_return_val_if_fail(backend_iface->set_decryption_parameters, FALSE);
218 return backend_iface->set_decryption_parameters(self,
219 sess_id, participant, cipher, auth, key, key_len);
222 void
223 purple_media_backend_set_params(PurpleMediaBackend *self,
224 guint num_params, GParameter *params)
226 g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
227 PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_params(self, num_params, params);
230 const gchar **
231 purple_media_backend_get_available_params(PurpleMediaBackend *self)
233 static const gchar *NULL_ARRAY[] = { NULL };
235 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL_ARRAY);
236 return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_available_params();
239 gboolean
240 purple_media_backend_set_send_rtcp_mux(PurpleMediaBackend *self,
241 const gchar *sess_id, const gchar *participant, gboolean send_rtcp_mux)
243 PurpleMediaBackendInterface *backend_iface;
245 g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), FALSE);
246 backend_iface = PURPLE_MEDIA_BACKEND_GET_INTERFACE(self);
247 g_return_val_if_fail(backend_iface->set_send_rtcp_mux, FALSE);
248 return backend_iface->set_send_rtcp_mux(self,
249 sess_id, participant, send_rtcp_mux);