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
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
24 #include "backend-iface.h"
31 ACTIVE_CANDIDATE_PAIR
,
35 static guint purple_media_backend_signals
[LAST_SIGNAL
] = {0};
38 purple_media_backend_base_init(gpointer iface
)
40 static gboolean is_initialized
= FALSE
;
45 g_object_interface_install_property(iface
,
46 g_param_spec_string("conference-type",
48 "The type of conference that this backend "
49 "has been created to provide.",
51 G_PARAM_CONSTRUCT_ONLY
| G_PARAM_READWRITE
|
52 G_PARAM_STATIC_STRINGS
));
53 g_object_interface_install_property(iface
,
59 "media", "Purple Media",
60 "The media object that this backend is bound to.",
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
,
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
;
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
,
116 iface_type
= g_type_register_static (G_TYPE_INTERFACE
,
117 "PurpleMediaBackend", &info
, 0);
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
,
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
);
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
,
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
,
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
);
175 purple_media_backend_set_remote_codecs(PurpleMediaBackend
*self
,
176 const gchar
*sess_id
, const gchar
*participant
,
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
);
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
,
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
);
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
);
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
);
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();
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
);