Fix an incorrect call to soup_message_set_request.
[pidgin-git.git] / libpurple / mediamanager.h
blobc13cc8d4abc1b14baa5d313106205c7b0cdfd93a
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_MANAGER_H
23 #define PURPLE_MEDIA_MANAGER_H
24 /**
25 * SECTION:mediamanager
26 * @section_id: libpurple-mediamanager
27 * @short_description: <filename>mediamanager.h</filename>
28 * @title: Media Manager Object
31 #include <glib.h>
32 #include <glib-object.h>
34 typedef struct _PurpleMediaManager PurpleMediaManager;
36 #include "account.h"
37 #include "media.h"
39 #define PURPLE_TYPE_MEDIA_MANAGER purple_media_manager_get_type()
41 /**
42 * PurpleMediaManagerClass:
44 * The media manager class.
46 struct _PurpleMediaManagerClass
48 GObjectClass parent_class;
50 /*< private >*/
51 void (*purple_reserved1)(void);
52 void (*purple_reserved2)(void);
53 void (*purple_reserved3)(void);
54 void (*purple_reserved4)(void);
57 /**
58 * PurpleMediaAppDataCallbacks:
59 * @readable: Called when the stream has received data and is readable.
60 * @writable: Called when the stream has become writable or has stopped being
61 * writable.
63 * A set of callbacks that can be installed on an Application data session with
64 * purple_media_manager_set_application_data_callbacks()
66 * Once installed the @readable callback will get called as long as data is
67 * available to read, so the data must be read completely.
68 * The @writable callback will only be called when the writable state of the
69 * stream changes. The @writable argument defines whether the stream has
70 * become writable or stopped being writable.
73 typedef struct {
74 void (*readable) (PurpleMediaManager *manager, PurpleMedia *media,
75 const gchar *session_id, const gchar *participant, gpointer user_data);
76 void (*writable) (PurpleMediaManager *manager, PurpleMedia *media,
77 const gchar *session_id, const gchar *participant, gboolean writable,
78 gpointer user_data);
79 } PurpleMediaAppDataCallbacks;
81 G_BEGIN_DECLS
83 /**************************************************************************/
84 /* Media Manager API */
85 /**************************************************************************/
87 /**
88 * purple_media_manager_get_type:
90 * Gets the media manager's GType.
92 * Returns: The media manager's GType.
94 G_DECLARE_FINAL_TYPE(PurpleMediaManager, purple_media_manager, PURPLE,
95 MEDIA_MANAGER, GObject)
97 /**
98 * purple_media_manager_get:
100 * Gets the "global" media manager object. It's created if it doesn't already exist.
102 * Returns: (transfer none): The "global" instance of the media manager object.
104 PurpleMediaManager *purple_media_manager_get(void);
107 * purple_media_manager_create_media:
108 * @manager: The media manager to create the session under.
109 * @account: The account to create the session on.
110 * @conference_type: The conference type to feed into Farstream.
111 * @remote_user: The remote user to initiate the session with.
112 * @initiator: TRUE if the local user is the initiator of this media call, FALSE otherwise.
114 * Creates a media session.
116 * Returns: (transfer full): A newly created media session.
118 PurpleMedia *purple_media_manager_create_media(PurpleMediaManager *manager,
119 PurpleAccount *account,
120 const char *conference_type,
121 const char *remote_user,
122 gboolean initiator);
125 * purple_media_manager_get_media:
126 * @manager: The media manager to get all of the sessions from.
128 * Gets all of the media sessions.
130 * Returns: (transfer none) (element-type PurpleMedia): A list of all the media sessions.
132 GList *purple_media_manager_get_media(PurpleMediaManager *manager);
135 * purple_media_manager_get_media_by_account:
136 * @manager: The media manager to get the sessions from.
137 * @account: The account the sessions are on.
139 * Gets all of the media sessions for a given account.
141 * Returns: (transfer container) (element-type PurpleMedia): A list of the media sessions on the given account.
143 GList *purple_media_manager_get_media_by_account(
144 PurpleMediaManager *manager, PurpleAccount *account);
147 * purple_media_manager_remove_media:
148 * @manager: The media manager to remove the media session from.
149 * @media: The media session to remove.
151 * Removes a media session from the media manager.
153 void
154 purple_media_manager_remove_media(PurpleMediaManager *manager,
155 PurpleMedia *media);
158 * purple_media_manager_create_private_media:
159 * @manager: The media manager to create the session under.
160 * @account: The account to create the session on.
161 * @conference_type: The conference type to feed into Farstream.
162 * @remote_user: The remote user to initiate the session with.
163 * @initiator: TRUE if the local user is the initiator of this media call, FALSE otherwise.
165 * Creates a private media session.
166 * A private media session is a media session which is private to the caller. It is
167 * meant to be used by plugins to create a media session that the front-end does not
168 * get notified about. It is useful especially for sessions with a type of
169 * PURPLE_MEDIA_APPLICATION which the front-end wouldn't know how to handle.
171 * Returns: (transfer full): A newly created media session.
173 PurpleMedia *purple_media_manager_create_private_media(
174 PurpleMediaManager *manager,
175 PurpleAccount *account,
176 const char *conference_type,
177 const char *remote_user,
178 gboolean initiator);
181 * purple_media_manager_get_private_media:
182 * @manager: The media manager to get all of the sessions from.
184 * Gets all of the private media sessions.
186 * Returns: (transfer none) (element-type PurpleMedia): A list of all the private media sessions.
188 GList *purple_media_manager_get_private_media(PurpleMediaManager *manager);
191 * purple_media_manager_get_private_media_by_account:
192 * @manager: The media manager to get the sessions from.
193 * @account: The account the sessions are on.
195 * Gets all of the private media sessions for a given account.
197 * Returns: (transfer container) (element-type PurpleMedia): A list of the private media sessions on the given account.
199 GList *purple_media_manager_get_private_media_by_account(
200 PurpleMediaManager *manager, PurpleAccount *account);
203 * purple_media_manager_create_output_window:
204 * @manager: Manager the output windows are registered with.
205 * @media: Media session the output windows are registered for.
206 * @session_id: The session the output windows are registered with.
207 * @participant: The participant the output windows are registered with.
209 * Signals that output windows should be created for the chosen stream.
211 * This shouldn't be called outside of mediamanager.c and media.c
213 * Returns: TRUE if it succeeded, FALSE if it failed.
215 gboolean purple_media_manager_create_output_window(
216 PurpleMediaManager *manager, PurpleMedia *media,
217 const gchar *session_id, const gchar *participant);
220 * purple_media_manager_set_output_window:
221 * @manager: The manager to register the output window with.
222 * @media: The media instance to find the stream in.
223 * @session_id: The session the stream is associated with.
224 * @participant: The participant the stream is associated with.
225 * @window_id: The window ID to embed the video in.
227 * Registers a video output window to be created for a given stream.
229 * Returns: A unique ID to the registered output window, 0 if it failed.
231 gulong purple_media_manager_set_output_window(PurpleMediaManager *manager,
232 PurpleMedia *media, const gchar *session_id,
233 const gchar *participant, gulong window_id);
236 * purple_media_manager_remove_output_window:
237 * @manager: The manager the output window was registered with.
238 * @output_window_id: The ID of the output window.
240 * Remove a previously registerd output window.
242 * Returns: TRUE if it found the output window and was successful, else FALSE.
244 gboolean purple_media_manager_remove_output_window(
245 PurpleMediaManager *manager, gulong output_window_id);
248 * purple_media_manager_remove_output_windows:
249 * @manager: The manager the output windows were registered with.
250 * @media: The media instance the output windows were registered for.
251 * @session_id: The session the output windows were registered for.
252 * @participant: The participant the output windows were registered for.
254 * Remove all output windows for a given conference/session/participant/stream.
256 void purple_media_manager_remove_output_windows(
257 PurpleMediaManager *manager, PurpleMedia *media,
258 const gchar *session_id, const gchar *participant);
261 * purple_media_manager_set_ui_caps:
262 * @manager: The manager to set the caps on.
263 * @caps: The caps to set.
265 * Sets which media caps the UI supports.
267 void purple_media_manager_set_ui_caps(PurpleMediaManager *manager,
268 PurpleMediaCaps caps);
271 * purple_media_manager_get_ui_caps:
272 * @manager: The manager to get caps from.
274 * Gets which media caps the UI supports.
276 * Returns: caps The caps retrieved.
278 PurpleMediaCaps purple_media_manager_get_ui_caps(PurpleMediaManager *manager);
281 * purple_media_manager_set_backend_type:
282 * @manager: The manager to set the caps on.
283 * @backend_type: The media backend type to use.
285 * Sets which media backend type media objects will use.
287 void purple_media_manager_set_backend_type(PurpleMediaManager *manager,
288 GType backend_type);
291 * purple_media_manager_get_backend_type:
292 * @manager: The manager to get the media backend type from.
294 * Gets which media backend type media objects will use.
296 * Returns: The type of media backend type media objects will use.
298 GType purple_media_manager_get_backend_type(PurpleMediaManager *manager);
301 * purple_media_manager_set_application_data_callbacks:
302 * @manager: The manager to register the callbacks with.
303 * @media: The media instance to register the callbacks with.
304 * @session_id: The session to register the callbacks with.
305 * @participant: The participant to register the callbacks with.
306 * @callbacks: The callbacks to be set on the session.
307 * @user_data: a user_data argument for the callbacks.
308 * @notify: a destroy notify function.
310 * Set callbacks on a session to be called when the stream becomes writable
311 * or readable for media sessions of type #PURPLE_MEDIA_APPLICATION
313 void purple_media_manager_set_application_data_callbacks(
314 PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
315 const gchar *participant, PurpleMediaAppDataCallbacks *callbacks,
316 gpointer user_data, GDestroyNotify notify);
319 * purple_media_manager_send_application_data:
320 * @manager: The manager to send data with.
321 * @media: The media instance to which the session belongs.
322 * @session_id: The session to send data to.
323 * @participant: The participant to send data to.
324 * @buffer: The buffer of data to send.
325 * @size: The size of @buffer
326 * @blocking: Whether to block until the data was send or not.
328 * Sends a buffer of data to a #PURPLE_MEDIA_APPLICATION session.
329 * If @blocking is set, unless an error occured, the function will not return
330 * until the data has been flushed into the network.
331 * If the stream is not writable, the data will be queued. It is the
332 * responsability of the user to stop sending data when the stream isn't
333 * writable anymore. It is also the responsability of the user to only start
334 * sending data after the stream has been configured correctly (encryption
335 * parameters for example).
337 * Returns: Number of bytes sent or -1 in case of error.
339 gint purple_media_manager_send_application_data (
340 PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
341 const gchar *participant, gpointer buffer, guint size, gboolean blocking);
344 * purple_media_manager_receive_application_data:
345 * @manager: The manager to receive data with.
346 * @media: The media instance to which the session belongs.
347 * @session_id: The session to receive data from.
348 * @participant: The participant to receive data from.
349 * @buffer: The buffer to receive data into.
350 * @max_size: The max_size of @buffer
351 * @blocking: Whether to block until the buffer is entirely filled or return
352 * with currently available data.
354 * Receive a buffer of data from a #PURPLE_MEDIA_APPLICATION session.
355 * If @blocking is set, unless an error occured, the function will not return
356 * until @max_size bytes are read.
358 * Returns: Number of bytes received or -1 in case of error.
360 gint purple_media_manager_receive_application_data (
361 PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
362 const gchar *participant, gpointer buffer, guint max_size,
363 gboolean blocking);
365 /*}@*/
367 G_END_DECLS
369 #endif /* PURPLE_MEDIA_MANAGER_H */