Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/mediamanager.h
branchadium-1.5.11-merge
changeset 6013 f8d0dc659e3f
parent 5941 307f53385811
parent 6012 200a01709ba4
child 6014 fcb71cb71a3d
child 6015 2b01cc935b7c
equal deleted inserted replaced
5941:307f53385811 6013:f8d0dc659e3f
     1 /**
       
     2  * @file mediamanager.h Media Manager API
       
     3  * @ingroup core
       
     4  */
       
     5 
       
     6 /* purple
       
     7  *
       
     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.
       
    11  *
       
    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.
       
    16  *
       
    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.
       
    21  *
       
    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
       
    25  */
       
    26 
       
    27 #ifndef _PURPLE_MEDIA_MANAGER_H_
       
    28 #define _PURPLE_MEDIA_MANAGER_H_
       
    29 
       
    30 #include <glib.h>
       
    31 #include <glib-object.h>
       
    32 
       
    33 /** An opaque structure representing a group of (usually all) media calls. */
       
    34 typedef struct _PurpleMediaManager PurpleMediaManager;
       
    35 /** The GObject class structure of the PurpleMediaManager object. */
       
    36 typedef struct _PurpleMediaManagerClass PurpleMediaManagerClass;
       
    37 
       
    38 #include "account.h"
       
    39 #include "media.h"
       
    40 
       
    41 /**
       
    42  * PurpleMediaAppDataCallbacks:
       
    43  * @readable: Called when the stream has received data and is readable.
       
    44  * @writable: Called when the stream has become writable or has stopped being
       
    45  * writable.
       
    46  *
       
    47  * A set of callbacks that can be installed on an Application data session with
       
    48  * purple_media_manager_set_application_data_callbacks()
       
    49  *
       
    50  * Once installed the @readable callback will get called as long as data is
       
    51  * available to read, so the data must be read completely.
       
    52  * The @writable callback will only be called when the writable state of the
       
    53  * stream changes. The @writable argument defines whether the stream has
       
    54  * become writable or stopped being writable.
       
    55  *
       
    56  */
       
    57 typedef struct {
       
    58 	void      (*readable)    (PurpleMediaManager *manager, PurpleMedia *media,
       
    59 		const gchar *session_id, const gchar *participant, gpointer user_data);
       
    60 	void      (*writable)    (PurpleMediaManager *manager, PurpleMedia *media,
       
    61 		const gchar *session_id, const gchar *participant, gboolean writable,
       
    62 		gpointer user_data);
       
    63 } PurpleMediaAppDataCallbacks;
       
    64 
       
    65 G_BEGIN_DECLS
       
    66 
       
    67 #define PURPLE_TYPE_MEDIA_MANAGER            (purple_media_manager_get_type())
       
    68 #define PURPLE_MEDIA_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_MANAGER, PurpleMediaManager))
       
    69 #define PURPLE_MEDIA_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MEDIA_MANAGER, PurpleMediaManagerClass))
       
    70 #define PURPLE_IS_MEDIA_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_MANAGER))
       
    71 #define PURPLE_IS_MEDIA_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MEDIA_MANAGER))
       
    72 #define PURPLE_MEDIA_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MEDIA_MANAGER, PurpleMediaManagerClass))
       
    73 
       
    74 #ifdef __cplusplus
       
    75 extern "C" {
       
    76 #endif
       
    77 
       
    78 /**************************************************************************/
       
    79 /** @name Media Manager API                                              */
       
    80 /**************************************************************************/
       
    81 /*@{*/
       
    82 
       
    83 /**
       
    84  * Gets the media manager's GType.
       
    85  *
       
    86  * @return The media manager's GType.
       
    87  *
       
    88  * @since 2.6.0
       
    89  */
       
    90 GType purple_media_manager_get_type(void);
       
    91 
       
    92 /**
       
    93  * Gets the "global" media manager object. It's created if it doesn't already exist.
       
    94  *
       
    95  * @return The "global" instance of the media manager object.
       
    96  *
       
    97  * @since 2.6.0
       
    98  */
       
    99 PurpleMediaManager *purple_media_manager_get(void);
       
   100 
       
   101 /**
       
   102  * Creates a media session.
       
   103  *
       
   104  * @param manager The media manager to create the session under.
       
   105  * @param account The account to create the session on.
       
   106  * @param conference_type The conference type to feed into Farsight2.
       
   107  * @param remote_user The remote user to initiate the session with.
       
   108  * @param initiator TRUE if the local user is the initiator of this media call, FALSE otherwise.
       
   109  *
       
   110  * @return A newly created media session.
       
   111  *
       
   112  * @since 2.6.0
       
   113  */
       
   114 PurpleMedia *purple_media_manager_create_media(PurpleMediaManager *manager,
       
   115 						PurpleAccount *account,
       
   116 						const char *conference_type,
       
   117 						const char *remote_user,
       
   118 						gboolean initiator);
       
   119 
       
   120 /**
       
   121  * Gets all of the media sessions.
       
   122  *
       
   123  * @param manager The media manager to get all of the sessions from.
       
   124  *
       
   125  * @return A list of all the media sessions.
       
   126  *
       
   127  * @since 2.6.0
       
   128  */
       
   129 GList *purple_media_manager_get_media(PurpleMediaManager *manager);
       
   130 
       
   131 /**
       
   132  * Gets all of the media sessions for a given account.
       
   133  *
       
   134  * @param manager The media manager to get the sessions from.
       
   135  * @param account The account the sessions are on.
       
   136  *
       
   137  * @return A list of the media sessions on the given account.
       
   138  *
       
   139  * @since 2.6.0
       
   140  */
       
   141 GList *purple_media_manager_get_media_by_account(
       
   142 		PurpleMediaManager *manager, PurpleAccount *account);
       
   143 
       
   144 /**
       
   145  * Removes a media session from the media manager.
       
   146  *
       
   147  * @param manager The media manager to remove the media session from.
       
   148  * @param media The media session to remove.
       
   149  *
       
   150  * @since 2.6.0
       
   151  */
       
   152 void
       
   153 purple_media_manager_remove_media(PurpleMediaManager *manager,
       
   154 				  PurpleMedia *media);
       
   155 
       
   156 /**
       
   157  * Creates a private media session.  A private media session is a
       
   158  * media session which is private to the caller. It is meant to be
       
   159  * used by plugins to create a media session that the front-end does
       
   160  * not get notified about. It is useful especially for sessions with a
       
   161  * type of PURPLE_MEDIA_APPLICATION which the front-end wouldn't know
       
   162  * how to handle.
       
   163  *
       
   164  * @param manager The media manager to create the session under.
       
   165  * @param account The account to create the session on.
       
   166  * @param conference_type The conference type to feed into Farsight2.
       
   167  * @param remote_user The remote user to initiate the session with.
       
   168  * @param initiator TRUE if the local user is the initiator of this media
       
   169  *        call, FALSE otherwise.
       
   170  *
       
   171  * @return A newly created media session.
       
   172  *
       
   173  * @since 2.11.0
       
   174  */
       
   175 PurpleMedia *purple_media_manager_create_private_media(
       
   176                                                 PurpleMediaManager *manager,
       
   177 						PurpleAccount *account,
       
   178 						const char *conference_type,
       
   179 						const char *remote_user,
       
   180 						gboolean initiator);
       
   181 
       
   182 /**
       
   183  * Gets all of the private media sessions.
       
   184  *
       
   185  * @param manager The media manager to get all of the sessions from.
       
   186  *
       
   187  * @return A list of all the private media sessions.
       
   188  *
       
   189  * @since 2.11.0
       
   190  */
       
   191 GList *purple_media_manager_get_private_media(PurpleMediaManager *manager);
       
   192 
       
   193 /**
       
   194  * Gets all of the private media sessions for a given account.
       
   195  *
       
   196  * @param manager The media manager to get the sessions from.
       
   197  * @param account The account the sessions are on.
       
   198  *
       
   199  * @return A list of the private media sessions on the given account.
       
   200  *
       
   201  * @since 2.11.0
       
   202  */
       
   203 GList *purple_media_manager_get_private_media_by_account(
       
   204 		PurpleMediaManager *manager, PurpleAccount *account);
       
   205 
       
   206 /**
       
   207  * Signals that output windows should be created for the chosen stream.
       
   208  *
       
   209  * This shouldn't be called outside of mediamanager.c and media.c
       
   210  *
       
   211  * @param manager Manager the output windows are registered with.
       
   212  * @param media Media session the output windows are registered for.
       
   213  * @param session_id The session the output windows are registered with.
       
   214  * @param participant The participant the output windows are registered with.
       
   215  *
       
   216  * @return TRUE if it succeeded, FALSE if it failed.
       
   217  *
       
   218  * @since 2.6.0
       
   219  */
       
   220 gboolean purple_media_manager_create_output_window(
       
   221 		PurpleMediaManager *manager, PurpleMedia *media,
       
   222 		const gchar *session_id, const gchar *participant);
       
   223 
       
   224 /**
       
   225  * Registers a video output window to be created for a given stream.
       
   226  *
       
   227  * @param manager The manager to register the output window with.
       
   228  * @param media The media instance to find the stream in.
       
   229  * @param session_id The session the stream is associated with.
       
   230  * @param participant The participant the stream is associated with.
       
   231  * @param window_id The window ID to embed the video in.
       
   232  *
       
   233  * @return A unique ID to the registered output window, 0 if it failed.
       
   234  *
       
   235  * @since 2.6.0
       
   236  */
       
   237 gulong purple_media_manager_set_output_window(PurpleMediaManager *manager,
       
   238 		PurpleMedia *media, const gchar *session_id,
       
   239 		const gchar *participant, gulong window_id);
       
   240 
       
   241 /**
       
   242  * Remove a previously registerd output window.
       
   243  *
       
   244  * @param manager The manager the output window was registered with.
       
   245  * @param output_window_id The ID of the output window.
       
   246  *
       
   247  * @return TRUE if it found the output window and was successful, else FALSE.
       
   248  *
       
   249  * @since 2.6.0
       
   250  */
       
   251 gboolean purple_media_manager_remove_output_window(
       
   252 		PurpleMediaManager *manager, gulong output_window_id);
       
   253 
       
   254 /**
       
   255  * Remove all output windows for a given conference/session/participant/stream.
       
   256  *
       
   257  * @param manager The manager the output windows were registered with.
       
   258  * @param media The media instance the output windows were registered for.
       
   259  * @param session_id The session the output windows were registered for.
       
   260  * @param participant The participant the output windows were registered for.
       
   261  *
       
   262  * @since 2.6.0
       
   263  */
       
   264 void purple_media_manager_remove_output_windows(
       
   265 		PurpleMediaManager *manager, PurpleMedia *media,
       
   266 		const gchar *session_id, const gchar *participant);
       
   267 
       
   268 /**
       
   269  * Sets which media caps the UI supports.
       
   270  *
       
   271  * @param manager The manager to set the caps on.
       
   272  * @param caps The caps to set.
       
   273  *
       
   274  * @since 2.6.0
       
   275  */
       
   276 void purple_media_manager_set_ui_caps(PurpleMediaManager *manager,
       
   277 		PurpleMediaCaps caps);
       
   278 
       
   279 /**
       
   280  * Gets which media caps the UI supports.
       
   281  *
       
   282  * @param manager The manager to get caps from.
       
   283  *
       
   284  * @return caps The caps retrieved.
       
   285  *
       
   286  * @since 2.6.0
       
   287  */
       
   288 PurpleMediaCaps purple_media_manager_get_ui_caps(PurpleMediaManager *manager);
       
   289 
       
   290 /**
       
   291  * Sets which media backend type media objects will use.
       
   292  *
       
   293  * @param manager The manager to set the caps on.
       
   294  * @param backend_type The media backend type to use.
       
   295  *
       
   296  * @since 2.7.0
       
   297  */
       
   298 void purple_media_manager_set_backend_type(PurpleMediaManager *manager,
       
   299 		GType backend_type);
       
   300 
       
   301 /**
       
   302  * Gets which media backend type media objects will use.
       
   303  *
       
   304  * @param manager The manager to get the media backend type from.
       
   305  *
       
   306  * @return The type of media backend type media objects will use.
       
   307  *
       
   308  * @since 2.7.0
       
   309  */
       
   310 GType purple_media_manager_get_backend_type(PurpleMediaManager *manager);
       
   311 
       
   312 /**
       
   313  * purple_media_manager_set_application_data_callbacks:
       
   314  * @manager: The manager to register the callbacks with.
       
   315  * @media: The media instance to register the callbacks with.
       
   316  * @session_id: The session to register the callbacks with.
       
   317  * @participant: The participant to register the callbacks with.
       
   318  * @callbacks: The callbacks to be set on the session.
       
   319  * @user_data: a user_data argument for the callbacks.
       
   320  * @notify: a destroy notify function.
       
   321  *
       
   322  * Set callbacks on a session to be called when the stream becomes writable
       
   323  * or readable for media sessions of type #PURPLE_MEDIA_APPLICATION
       
   324  */
       
   325 void purple_media_manager_set_application_data_callbacks(
       
   326 	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
       
   327 	const gchar *participant, PurpleMediaAppDataCallbacks *callbacks,
       
   328 	gpointer user_data, GDestroyNotify notify);
       
   329 
       
   330 /**
       
   331  * purple_media_manager_send_application_data:
       
   332  * @manager: The manager to send data with.
       
   333  * @media: The media instance to which the session belongs.
       
   334  * @session_id: The session to send data to.
       
   335  * @participant: The participant to send data to.
       
   336  * @buffer: The buffer of data to send.
       
   337  * @size: The size of @buffer
       
   338  * @blocking: Whether to block until the data was send or not.
       
   339  *
       
   340  * Sends a buffer of data to a #PURPLE_MEDIA_APPLICATION session.
       
   341  * If @blocking is set, unless an error occured, the function will not return
       
   342  * until the data has been flushed into the network.
       
   343  * If the stream is not writable, the data will be queued. It is the
       
   344  * responsability of the user to stop sending data when the stream isn't
       
   345  * writable anymore. It is also the responsability of the user to only start
       
   346  * sending data after the stream has been configured correctly (encryption
       
   347  * parameters for example).
       
   348  *
       
   349  * Returns: Number of bytes sent or -1 in case of error.
       
   350  */
       
   351 gint purple_media_manager_send_application_data (
       
   352 	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
       
   353 	const gchar *participant, gpointer buffer, guint size, gboolean blocking);
       
   354 
       
   355 /**
       
   356  * purple_media_manager_receive_application_data:
       
   357  * @manager: The manager to receive data with.
       
   358  * @media: The media instance to which the session belongs.
       
   359  * @session_id: The session to receive data from.
       
   360  * @participant: The participant to receive data from.
       
   361  * @buffer: The buffer to receive data into.
       
   362  * @max_size: The max_size of @buffer
       
   363  * @blocking: Whether to block until the buffer is entirely filled or return
       
   364  * with currently available data.
       
   365  *
       
   366  * Receive a buffer of data from a #PURPLE_MEDIA_APPLICATION session.
       
   367  * If @blocking is set, unless an error occured, the function will not return
       
   368  * until @max_size bytes are read.
       
   369  *
       
   370  * Returns: Number of bytes received or -1 in case of error.
       
   371  */
       
   372 gint purple_media_manager_receive_application_data (
       
   373 	PurpleMediaManager *manager, PurpleMedia *media, const gchar *session_id,
       
   374 	const gchar *participant, gpointer buffer, guint max_size,
       
   375 	gboolean blocking);
       
   376 
       
   377 /*}@*/
       
   378 
       
   379 #ifdef __cplusplus
       
   380 }
       
   381 #endif
       
   382 
       
   383 G_END_DECLS
       
   384 
       
   385 #endif  /* _PURPLE_MEDIA_MANAGER_H_ */