Replace g_list_remove_link+g_list_free_1 with g_list_delete_link
[pidgin-git.git] / libpurple / media.h
blobf7ed18ff3e99ce96eb815d63f5d0e33728efc633
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 #ifndef PURPLE_MEDIA_H
23 #define PURPLE_MEDIA_H
24 /**
25 * SECTION:media
26 * @section_id: libpurple-media
27 * @short_description: <filename>media.h</filename>
28 * @title: Media Object API
31 #include <glib.h>
32 #include <glib-object.h>
34 typedef struct _PurpleMedia PurpleMedia;
36 #include "media/candidate.h"
37 #include "media/codec.h"
38 #include "media/enum-types.h"
40 #define PURPLE_TYPE_MEDIA (purple_media_get_type())
41 #define PURPLE_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA, PurpleMedia))
42 #define PURPLE_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA, PurpleMediaClass))
43 #define PURPLE_IS_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA))
44 #define PURPLE_IS_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA))
45 #define PURPLE_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA, PurpleMediaClass))
47 #include "signals.h"
48 #include "util.h"
50 #ifdef USE_VV
52 typedef struct _PurpleMediaClass PurpleMediaClass;
53 typedef struct _PurpleMediaPrivate PurpleMediaPrivate;
55 /**
56 * PurpleMedia:
58 * The media instance
60 struct _PurpleMedia
62 GObject parent;
64 /*< private >*/
65 PurpleMediaPrivate *priv;
68 /**
69 * PurpleMediaClass:
71 * The media class
73 struct _PurpleMediaClass
75 GObjectClass parent_class;
77 /*< private >*/
78 void (*purple_reserved1)(void);
79 void (*purple_reserved2)(void);
80 void (*purple_reserved3)(void);
81 void (*purple_reserved4)(void);
84 #endif
86 G_BEGIN_DECLS
88 /**
89 * purple_media_get_type:
91 * Gets the media class's GType
93 * Returns: The media class's GType.
95 GType purple_media_get_type(void);
97 /**
98 * purple_media_get_session_ids:
99 * @media: The media session from which to retrieve session IDs.
101 * Gets a list of session IDs.
103 * Returns: (element-type utf8) (transfer container): List of session IDs.
105 GList *purple_media_get_session_ids(PurpleMedia *media);
108 * purple_media_get_account:
109 * @media: The media session to retrieve the account from.
111 * Gets the PurpleAccount this media session is on.
113 * Returns: (transfer none): The account retrieved.
115 PurpleAccount *purple_media_get_account(PurpleMedia *media);
118 * purple_media_get_protocol_data:
119 * @media: The media session to retrieve the protocol data from.
121 * Gets the protocol data from the media session.
123 * Returns: The protocol data retrieved.
125 gpointer purple_media_get_protocol_data(PurpleMedia *media);
128 * purple_media_set_protocol_data:
129 * @media: The media session to set the protocol data on.
130 * @protocol_data: The data to set on the media session.
132 * Sets the protocol data on the media session.
134 void purple_media_set_protocol_data(PurpleMedia *media, gpointer protocol_data);
137 * purple_media_error:
138 * @media: The media object to set the state on.
139 * @error: The format of the error message to send in the signal.
140 * @...: The arguments to plug into the format.
142 * Signals an error in the media session.
144 void purple_media_error(PurpleMedia *media, const gchar *error, ...);
147 * purple_media_end:
148 * @media: The media object with which to end streams.
149 * @session_id: The session to end streams on.
150 * @participant: The participant to end streams with.
152 * Ends all streams that match the given parameters
154 void purple_media_end(PurpleMedia *media, const gchar *session_id,
155 const gchar *participant);
158 * purple_media_stream_info:
159 * @media: The media instance to containing the stream to signal.
160 * @type: The type of info being signaled.
161 * @session_id: The id of the session of the stream being signaled.
162 * @participant: The participant of the stream being signaled.
163 * @local: TRUE if the info originated locally, FALSE if on the remote end.
165 * Signals different information about the given stream.
167 void purple_media_stream_info(PurpleMedia *media, PurpleMediaInfoType type,
168 const gchar *session_id, const gchar *participant,
169 gboolean local);
172 * purple_media_set_params:
173 * @media: The media object to set the parameters on.
174 * @num_params: The number of parameters to pass
175 * @params: Array of @c GParameter to pass
177 * Sets various optional parameters of the media call.
179 * Currently supported are:
180 * - "sdes-cname" : The CNAME for the RTP sessions
181 * - "sdes-name" : Real name used to describe the source in SDES messages
182 * - "sdes-tool" : The TOOL to put in SDES messages
183 * - "sdes-email" : Email address to put in SDES messages
184 * - "sdes-location" : The LOCATION to put in SDES messages
185 * - "sdes-note" : The NOTE to put in SDES messages
186 * - "sdes-phone" : The PHONE to put in SDES messages
188 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
189 void purple_media_set_params(PurpleMedia *media,
190 guint num_params, GParameter *params);
191 G_GNUC_END_IGNORE_DEPRECATIONS
194 * purple_media_get_available_params:
195 * @media: The media object
197 * Gets the list of optional parameters supported by the media backend.
199 * The list is owned by the #PurpleMedia internals and should NOT be freed.
201 * Returns: (array zero-terminated=1) (transfer none): Names of supported
202 * parameters.
204 const gchar **purple_media_get_available_params(PurpleMedia *media);
207 * purple_media_param_is_supported:
208 * @media: The media object
209 * @param: name of parameter
211 * Checks if given optional parameter is supported by the media backend.
213 * Returns: %TRUE if backend recognizes the parameter, %FALSE otherwise.
215 gboolean purple_media_param_is_supported(PurpleMedia *media, const gchar *param);
218 * purple_media_add_stream:
219 * @media: The media object to find the session in.
220 * @sess_id: The session id of the session to add the stream to.
221 * @who: The name of the remote user to add the stream for.
222 * @type: The type of stream to create.
223 * @initiator: Whether or not the local user initiated the stream.
224 * @transmitter: The transmitter to use for the stream.
225 * @num_params: The number of parameters to pass to Farstream.
226 * @params: The parameters to pass to Farstream.
228 * Adds a stream to a session.
230 * It only adds a stream to one audio session or video session as
231 * the @sess_id must be unique between sessions.
233 * Returns: %TRUE The stream was added successfully, %FALSE otherwise.
235 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
236 gboolean purple_media_add_stream(PurpleMedia *media, const gchar *sess_id,
237 const gchar *who, PurpleMediaSessionType type,
238 gboolean initiator, const gchar *transmitter,
239 guint num_params, GParameter *params);
240 G_GNUC_END_IGNORE_DEPRECATIONS
243 * purple_media_get_session_type:
244 * @media: The media object to find the session in.
245 * @sess_id: The session id of the session to get the type from.
247 * Gets the session type from a session
249 * Returns: The retreived session type.
251 PurpleMediaSessionType purple_media_get_session_type(PurpleMedia *media, const gchar *sess_id);
254 * purple_media_get_manager:
255 * @media: The media object to get the manager instance from.
257 * Gets the PurpleMediaManager this media session is a part of.
259 * Returns: The PurpleMediaManager instance retrieved.
261 struct _PurpleMediaManager *purple_media_get_manager(PurpleMedia *media);
264 * purple_media_get_codecs:
265 * @media: The media object to find the session in.
266 * @sess_id: The session id of the session to get the codecs from.
268 * Gets the codecs from a session.
270 * Returns: (element-type PurpleMediaCodec) (transfer full): The retrieved
271 * codecs.
273 GList *purple_media_get_codecs(PurpleMedia *media, const gchar *sess_id);
276 * purple_media_add_remote_candidates:
277 * @media: The media object to find the session in.
278 * @sess_id: The session id of the session find the stream in.
279 * @participant: The name of the remote user to add the candidates for.
280 * @remote_candidates: (element-type PurpleMediaCandidate) (transfer none): The
281 * remote candidates to add.
283 * Adds remote candidates to the stream.
285 void purple_media_add_remote_candidates(PurpleMedia *media,
286 const gchar *sess_id,
287 const gchar *participant,
288 GList *remote_candidates);
291 * purple_media_get_local_candidates:
292 * @media: The media object to find the session in.
293 * @sess_id: The session id of the session to find the stream in.
294 * @participant: The name of the remote user to get the candidates from.
296 * Gets the local candidates from a stream.
298 * Returns: (element-type PurpleMediaCandidate) (transfer full): The local
299 * candidates.
301 GList *purple_media_get_local_candidates(PurpleMedia *media,
302 const gchar *sess_id,
303 const gchar *participant);
306 * purple_media_get_active_local_candidates:
307 * @media: The media object to find the session in.
308 * @sess_id: The session id of the session to find the stream in.
309 * @participant: The name of the remote user to get the active candidate
310 * from.
312 * Gets the active local candidates for the stream.
314 * Returns: (element-type PurpleMediaCandidate) (transfer full): The active
315 * candidates retrieved.
317 GList *purple_media_get_active_local_candidates(PurpleMedia *media,
318 const gchar *sess_id, const gchar *participant);
321 * purple_media_get_active_remote_candidates:
322 * @media: The media object to find the session in.
323 * @sess_id: The session id of the session to find the stream in.
324 * @participant: The name of the remote user to get the remote candidate
325 * from.
327 * Gets the active remote candidates for the stream.
329 * Returns: (element-type PurpleMediaCandidate) (transfer full): The remote
330 * candidates retrieved.
332 GList *purple_media_get_active_remote_candidates(PurpleMedia *media,
333 const gchar *sess_id, const gchar *participant);
336 * purple_media_set_remote_codecs:
337 * @media: The media object to find the session in.
338 * @sess_id: The session id of the session find the stream in.
339 * @participant: The name of the remote user to set the codecs for.
340 * @codecs: (element-type PurpleMediaCodec) (transfer none): The list of remote
341 * codecs to set.
343 * Sets remote codecs from the stream.
345 * Returns: %TRUE The codecs were set successfully, or %FALSE otherwise.
347 gboolean purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id,
348 const gchar *participant, GList *codecs);
351 * purple_media_candidates_prepared:
352 * @media: The media object to find the remote user in.
353 * @session_id: The session id of the session to check.
354 * @participant: The remote user to check for.
356 * Returns whether or not the candidates for set of streams are prepared
358 * Returns: %TRUE All streams for the given session_id/participant combination have candidates prepared, %FALSE otherwise.
360 gboolean purple_media_candidates_prepared(PurpleMedia *media,
361 const gchar *session_id, const gchar *participant);
364 * purple_media_set_send_codec:
365 * @media: The media object to find the session in.
366 * @sess_id: The session id of the session to set the codec for.
367 * @codec: The codec to set the session to stream.
369 * Sets the send codec for the a session.
371 * Returns: %TRUE The codec was successfully changed, or %FALSE otherwise.
373 gboolean purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, PurpleMediaCodec *codec);
376 * purple_media_set_encryption_parameters:
377 * @media: The media object to find the session in.
378 * @sess_id: The session id of the session to set parameters of.
379 * @cipher: The cipher to use to encrypt our media in the session.
380 * @auth: The algorithm to use to compute authentication codes for our media
381 * frames.
382 * @key: The encryption key.
383 * @key_len: Byte length of the encryption key.
385 * Sets the encryption parameters of our media in the session.
387 gboolean purple_media_set_encryption_parameters(PurpleMedia *media,
388 const gchar *sess_id, const gchar *cipher,
389 const gchar *auth, const gchar *key, gsize key_len);
392 * purple_media_set_decryption_parameters:
393 * @media: The media object to find the session in.
394 * @sess_id: The session id of the session to set parameters of.
395 * @participant: The participant of the session to set parameters of.
396 * @cipher: The cipher to use to decrypt media coming from this session's
397 * participant.
398 * @auth: The algorithm to use for authentication of the media coming from
399 * the session's participant.
400 * @key: The decryption key.
401 * @key_len: Byte length of the decryption key.
403 * Sets the decryption parameters for a session participant's media.
405 gboolean purple_media_set_decryption_parameters(PurpleMedia *media,
406 const gchar *sess_id, const gchar *participant,
407 const gchar *cipher, const gchar *auth,
408 const gchar *key, gsize key_len);
411 * purple_media_codecs_ready:
412 * @media: The media object to find the session in.
413 * @sess_id: The session id of the session to check.
415 * Gets whether a session's codecs are ready to be used.
417 * Returns: %TRUE The codecs are ready, or %FALSE otherwise.
419 gboolean purple_media_codecs_ready(PurpleMedia *media, const gchar *sess_id);
422 * purple_media_set_send_rtcp_mux:
423 * @media: The media object to find the session in.
424 * @sess_id: The session id of the session find the stream in.
425 * @participant: The name of the remote user to set the rtcp-mux for.
426 * @send_rtcp_mux: Whether to enable the rtcp-mux option
428 * Sets the rtcp-mux option for the stream.
430 * Returns: %TRUE RTCP-Mux was set successfully, or %FALSE otherwise.
432 * @since 2.11.0
434 gboolean purple_media_set_send_rtcp_mux(PurpleMedia *media,
435 const gchar *sess_id, const gchar *participant, gboolean send_rtcp_mux);
437 * purple_media_is_initiator:
438 * @media: The media instance to find the session in.
439 * @sess_id: The session id of the session to check.
440 * @participant: The participant of the stream to check.
442 * Gets whether the local user is the conference/session/stream's initiator.
444 * Returns: TRUE if the local user is the stream's initator, else FALSE.
446 gboolean purple_media_is_initiator(PurpleMedia *media,
447 const gchar *sess_id, const gchar *participant);
450 * purple_media_accepted:
451 * @media: The media object to find the session in.
452 * @sess_id: The session id of the session to check.
453 * @participant: The participant to check.
455 * Gets whether a streams selected have been accepted.
457 * Returns: %TRUE The selected streams have been accepted, or %FALSE otherwise.
459 gboolean purple_media_accepted(PurpleMedia *media, const gchar *sess_id,
460 const gchar *participant);
463 * purple_media_set_input_volume:
464 * @media: The media object the sessions are in.
465 * @session_id: The session to select (if any).
466 * @level: The level to set the volume to.
468 * Sets the input volume of all the selected sessions.
470 void purple_media_set_input_volume(PurpleMedia *media, const gchar *session_id, double level);
473 * purple_media_set_output_volume:
474 * @media: The media object the streams are in.
475 * @session_id: The session to limit the streams to (if any).
476 * @participant: The participant to limit the streams to (if any).
477 * @level: The level to set the volume to.
479 * Sets the output volume of all the selected streams.
481 void purple_media_set_output_volume(PurpleMedia *media, const gchar *session_id,
482 const gchar *participant, double level);
485 * purple_media_set_output_window:
486 * @media: The media instance to set the output window on.
487 * @session_id: The session to set the output window on.
488 * @participant: Optionally, the participant to set the output window on.
489 * @window_id: The window id use for embedding the video in.
491 * Sets a video output window for the given session/stream.
493 * Returns: An id to reference the output window.
495 gulong purple_media_set_output_window(PurpleMedia *media,
496 const gchar *session_id, const gchar *participant,
497 gulong window_id);
500 * purple_media_remove_output_windows:
501 * @media: The instance to remove all output windows from.
503 * Removes all output windows from a given media session.
505 void purple_media_remove_output_windows(PurpleMedia *media);
508 * purple_media_send_dtmf:
509 * @media: The media instance to send a DTMF signal to.
510 * @session_id: The session id of the session to send the DTMF signal on.
511 * @dtmf: The character representing the DTMF in the range [0-9#*A-D].
512 * @volume: The power level expressed in dBm0 after dropping the sign in the
513 * range of 0 to 63. A larger value represents a lower volume.
514 * @duration: The duration of the tone in milliseconds.
516 * Sends a DTMF signal out-of-band.
518 * Returns: %TRUE DTMF sent successfully, or %FALSE otherwise.
520 gboolean purple_media_send_dtmf(PurpleMedia *media, const gchar *session_id,
521 gchar dtmf, guint8 volume, guint16 duration);
523 G_END_DECLS
525 #endif /* PURPLE_MEDIA_H */