Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/media/backend-iface.h
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     1 /**
       
     2  * @file backend-iface.h Interface for media backends
       
     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 _MEDIA_BACKEND_IFACE_H_
       
    28 #define _MEDIA_BACKEND_IFACE_H_
       
    29 
       
    30 #include "codec.h"
       
    31 #include "enum-types.h"
       
    32 
       
    33 #include <glib-object.h>
       
    34 
       
    35 G_BEGIN_DECLS
       
    36 
       
    37 #define PURPLE_TYPE_MEDIA_BACKEND		(purple_media_backend_get_type())
       
    38 #define PURPLE_IS_MEDIA_BACKEND(obj)		(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_MEDIA_BACKEND))
       
    39 #define PURPLE_MEDIA_BACKEND(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_MEDIA_BACKEND, PurpleMediaBackend))
       
    40 #define PURPLE_MEDIA_BACKEND_GET_INTERFACE(inst)(G_TYPE_INSTANCE_GET_INTERFACE((inst), PURPLE_TYPE_MEDIA_BACKEND, PurpleMediaBackendIface))
       
    41 
       
    42 /** A placeholder to represent any media backend */
       
    43 typedef struct _PurpleMediaBackend PurpleMediaBackend;
       
    44 /** A structure to derive media backends from. */
       
    45 typedef struct _PurpleMediaBackendIface PurpleMediaBackendIface;
       
    46 
       
    47 struct _PurpleMediaBackendIface
       
    48 {
       
    49 	GTypeInterface parent_iface; /**< The parent iface class */
       
    50 
       
    51 	/** Implementable functions called with purple_media_backend_* */
       
    52 	gboolean (*add_stream) (PurpleMediaBackend *self,
       
    53 		const gchar *sess_id, const gchar *who,
       
    54 		PurpleMediaSessionType type, gboolean initiator,
       
    55 		const gchar *transmitter,
       
    56 		guint num_params, GParameter *params);
       
    57 	void (*add_remote_candidates) (PurpleMediaBackend *self,
       
    58 		const gchar *sess_id, const gchar *participant,
       
    59 		GList *remote_candidates);
       
    60 	gboolean (*codecs_ready) (PurpleMediaBackend *self,
       
    61 		const gchar *sess_id);
       
    62 	GList *(*get_codecs) (PurpleMediaBackend *self,
       
    63 		const gchar *sess_id);
       
    64 	GList *(*get_local_candidates) (PurpleMediaBackend *self,
       
    65 		const gchar *sess_id, const gchar *participant);
       
    66 	gboolean (*set_remote_codecs) (PurpleMediaBackend *self,
       
    67 		const gchar *sess_id, const gchar *participant,
       
    68 		GList *codecs);
       
    69 	gboolean (*set_send_codec) (PurpleMediaBackend *self,
       
    70 		const gchar *sess_id, PurpleMediaCodec *codec);
       
    71 	gboolean (*set_encryption_parameters) (PurpleMediaBackend *self,
       
    72 		const gchar *sess_id, const gchar *cipher,
       
    73 		const gchar *auth, const gchar *key, gsize key_len);
       
    74 	gboolean (*set_decryption_parameters) (PurpleMediaBackend *self,
       
    75 		const gchar *sess_id, const gchar *participant,
       
    76 		const gchar *cipher, const gchar *auth,
       
    77 		const gchar *key, gsize key_len);
       
    78 	void (*set_params) (PurpleMediaBackend *self,
       
    79 		guint num_params, GParameter *params);
       
    80 	const gchar **(*get_available_params) (void);
       
    81 	gboolean (*send_dtmf) (PurpleMediaBackend *self,
       
    82 		const gchar *sess_id, gchar dtmf, guint8 volume,
       
    83 		guint16 duration);
       
    84 	gboolean (*set_send_rtcp_mux) (PurpleMediaBackend *self,
       
    85 		const gchar *sess_id, const gchar *participant, gboolean send_rtcp_mux);
       
    86 };
       
    87 
       
    88 /**
       
    89  * Gets the media backend's GType.
       
    90  *
       
    91  * @return The media backend's GType.
       
    92  *
       
    93  * @since 2.7.0
       
    94  */
       
    95 GType purple_media_backend_get_type(void);
       
    96 
       
    97 /**
       
    98  * Creates and adds a stream to the media backend.
       
    99  *
       
   100  * @param self The backend to add the stream to.
       
   101  * @param sess_id The session id of the stream to add.
       
   102  * @param who The remote participant of the stream to add.
       
   103  * @param type The media type and direction of the stream to add.
       
   104  * @param initiator True if the local user initiated the stream.
       
   105  * @param transmitter The string id of the tranmsitter to use.
       
   106  * @param num_params The number of parameters in the param parameter.
       
   107  * @param params The additional parameters to pass when creating the stream.
       
   108  *
       
   109  * @return True if the stream was successfully created, othewise False.
       
   110  *
       
   111  * @since 2.7.0
       
   112  */
       
   113 gboolean purple_media_backend_add_stream(PurpleMediaBackend *self,
       
   114 		const gchar *sess_id, const gchar *who,
       
   115 		PurpleMediaSessionType type, gboolean initiator,
       
   116 		const gchar *transmitter,
       
   117 		guint num_params, GParameter *params);
       
   118 
       
   119 /**
       
   120  * Add remote candidates to a stream.
       
   121  *
       
   122  * @param self The backend the stream is in.
       
   123  * @param sess_id The session id associated with the stream.
       
   124  * @param participant The participant associated with the stream.
       
   125  * @param remote_candidates The list of remote candidates to add.
       
   126  *
       
   127  * @since 2.7.0
       
   128  */
       
   129 void purple_media_backend_add_remote_candidates(PurpleMediaBackend *self,
       
   130 		const gchar *sess_id, const gchar *participant,
       
   131 		GList *remote_candidates);
       
   132 
       
   133 /**
       
   134  * Get whether or not a session's codecs are ready.
       
   135  *
       
   136  * A codec is ready if all of the attributes and additional
       
   137  * parameters have been collected.
       
   138  *
       
   139  * @param self The media backend the session is in.
       
   140  * @param sess_id The session id of the session to check.
       
   141  *
       
   142  * @return True if the codecs are ready, otherwise False.
       
   143  *
       
   144  * @since 2.7.0
       
   145  */
       
   146 gboolean purple_media_backend_codecs_ready(PurpleMediaBackend *self,
       
   147 		const gchar *sess_id);
       
   148 
       
   149 /**
       
   150  * Gets the codec intersection list for a session.
       
   151  *
       
   152  * The intersection list consists of all codecs that are compatible
       
   153  * between the local and remote software.
       
   154  *
       
   155  * @param self The media backend the session is in.
       
   156  * @param sess_id The session id of the session to use.
       
   157  *
       
   158  * @return The codec intersection list.
       
   159  *
       
   160  * @since 2.7.0
       
   161  */
       
   162 GList *purple_media_backend_get_codecs(PurpleMediaBackend *self,
       
   163 		const gchar *sess_id);
       
   164 
       
   165 /**
       
   166  * Gets the list of local candidates for a stream.
       
   167  *
       
   168  * @param self The media backend the stream is in.
       
   169  * @param sess_id The session id associated with the stream.
       
   170  * @param particilant The participant associated with the stream.
       
   171  *
       
   172  * @return The list of local candidates.
       
   173  *
       
   174  * @since 2.7.0
       
   175  */
       
   176 GList *purple_media_backend_get_local_candidates(PurpleMediaBackend *self,
       
   177 		const gchar *sess_id, const gchar *participant);
       
   178 
       
   179 /**
       
   180  * Sets the remote codecs on a stream.
       
   181  *
       
   182  * @param self The media backend the stream is in.
       
   183  * @param sess_id The session id the stream is associated with.
       
   184  * @param participant The participant the stream is associated with.
       
   185  * @param codecs The list of remote codecs to set.
       
   186  *
       
   187  * @return True if the remote codecs were set successfully, otherwise False.
       
   188  *
       
   189  * @since 2.7.0
       
   190  */
       
   191 gboolean purple_media_backend_set_remote_codecs(PurpleMediaBackend *self,
       
   192 		const gchar *sess_id, const gchar *participant,
       
   193 		GList *codecs);
       
   194 
       
   195 /**
       
   196  * Sets which codec format to send media content in for a session.
       
   197  *
       
   198  * @param self The media backend the session is in.
       
   199  * @param sess_id The session id of the session to set the codec for.
       
   200  * @param codec The codec to set.
       
   201  *
       
   202  * @return True if set successfully, otherwise False.
       
   203  *
       
   204  * @since 2.7.0
       
   205  */
       
   206 gboolean purple_media_backend_set_send_codec(PurpleMediaBackend *self,
       
   207 		const gchar *sess_id, PurpleMediaCodec *codec);
       
   208 
       
   209 /**
       
   210  * Sets the encryption parameters of our media in the session.
       
   211  *
       
   212  * @param self The media backend the session is in.
       
   213  * @param sess_id The session id of the session to set parameters of.
       
   214  * @param cipher The cipher to use to encrypt our media in the session.
       
   215  * @param auth The algorithm to use to compute authentication codes for our
       
   216  *        media frames.
       
   217  * @param key The encryption key.
       
   218  * @param key_len Byte length of the encryption key.
       
   219  *
       
   220  * @since 2.11.0
       
   221  */
       
   222 gboolean purple_media_backend_set_encryption_parameters(PurpleMediaBackend *self,
       
   223 		const gchar *sess_id, const gchar *cipher,
       
   224 		const gchar *auth, const gchar *key, gsize key_len);
       
   225 
       
   226 /**
       
   227  * Sets the decryption parameters for a session participant's media.
       
   228  *
       
   229  * @param self The media backend the session is in.
       
   230  * @param sess_id The session id of the session to set parameters of.
       
   231  * @param participant The participant of the session to set parameters of.
       
   232  * @param cipher The cipher to use to decrypt media coming from this session's
       
   233  *          participant.
       
   234  * @param auth The algorithm to use for authentication of the media coming
       
   235  *        from the session's participant.
       
   236  * @param key The decryption key.
       
   237  * @param key_len Byte length of the decryption key.
       
   238  *
       
   239  * @since 2.11.0
       
   240  */
       
   241 gboolean purple_media_backend_set_decryption_parameters(PurpleMediaBackend *self,
       
   242 		const gchar *sess_id, const gchar *participant,
       
   243 		const gchar *cipher, const gchar *auth,
       
   244 		const gchar *key, gsize key_len);
       
   245 
       
   246 /**
       
   247  * Sets various optional parameters of the media backend.
       
   248  *
       
   249  * @param self The media backend to set the parameters on.
       
   250  * @param num_params The number of parameters to pass to backend
       
   251  * @param params Array of @c GParameter to pass to backend
       
   252  *
       
   253  * @since 2.8.0
       
   254  */
       
   255 void purple_media_backend_set_params(PurpleMediaBackend *self,
       
   256 		guint num_params, GParameter *params);
       
   257 
       
   258 /**
       
   259  * Gets the list of optional parameters supported by the media backend.
       
   260  *
       
   261  * The list should NOT be freed.
       
   262  *
       
   263  * @param self The media backend
       
   264  *
       
   265  * @return NULL-terminated array of names of supported parameters.
       
   266  *
       
   267  * @since 2.8.0
       
   268  */
       
   269 const gchar **purple_media_backend_get_available_params(PurpleMediaBackend *self);
       
   270 
       
   271 /**
       
   272  * purple_media_backend_set_send_rtcp_mux:
       
   273  * @self: The media backend the session is in.
       
   274  * @sess_id: The session id of the session to set the rtcp-mux option to
       
   275  * @participant: The participant the stream is associated with.
       
   276  * @send_rtcp_mux: Whether or not to enable rtcp-mux
       
   277  *
       
   278  * Controls whether or not the RTCP should be muxed with the RTP
       
   279  *
       
   280  * Returns: True if set successfully, otherwise False.
       
   281  */
       
   282 gboolean purple_media_backend_set_send_rtcp_mux(PurpleMediaBackend *self,
       
   283 		const gchar *sess_id, const gchar *participant, gboolean send_rtcp_mux);
       
   284 
       
   285 
       
   286 G_END_DECLS
       
   287 
       
   288 #endif /* _MEDIA_BACKEND_IFACE_H_ */