1 /* 2 * Farstream - Farstream Session 3 * 4 * Copyright 2007 Collabora Ltd. 5 * @author: Philippe Kalaf <philippe.kalaf@collabora.co.uk> 6 * Copyright 2007 Nokia Corp. 7 * 8 * fs-session.h - A Farstream Session gobject (base implementation) 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef __FS_SESSION_H__ 26 #define __FS_SESSION_H__ 27 28 #include <glib.h> 29 #include <glib-object.h> 30 31 #include <farstream/fs-stream.h> 32 #include <farstream/fs-participant.h> 33 #include <farstream/fs-codec.h> 34 35 G_BEGIN_DECLS 36 37 /* TYPE MACROS */ 38 #define FS_TYPE_SESSION \ 39 (fs_session_get_type ()) 40 #define FS_SESSION(obj) \ 41 (G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_SESSION, FsSession)) 42 #define FS_SESSION_CLASS(klass) \ 43 (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_SESSION, FsSessionClass)) 44 #define FS_IS_SESSION(obj) \ 45 (G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_SESSION)) 46 #define FS_IS_SESSION_CLASS(klass) \ 47 (G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_SESSION)) 48 #define FS_SESSION_GET_CLASS(obj) \ 49 (G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_SESSION, FsSessionClass)) 50 #define FS_SESSION_CAST(obj) ((FsSession *) (obj)) 51 52 typedef struct _FsSession FsSession; 53 typedef struct _FsSessionClass FsSessionClass; 54 typedef struct _FsSessionPrivate FsSessionPrivate; 55 56 /** 57 * FsDTMFEvent: 58 * 59 * An enum that represents the different DTMF event that can be sent to a 60 * #FsSession. The values corresponds those those defined in RFC 4733 61 * The rest of the possibles values are in the IANA registry at: 62 * http://www.iana.org/assignments/audio-telephone-event-registry 63 * 64 */ 65 typedef enum _FsDTMFEvent 66 { 67 /*< protected >*/ 68 FS_DTMF_EVENT_0 = 0, 69 FS_DTMF_EVENT_1 = 1, 70 FS_DTMF_EVENT_2 = 2, 71 FS_DTMF_EVENT_3 = 3, 72 FS_DTMF_EVENT_4 = 4, 73 FS_DTMF_EVENT_5 = 5, 74 FS_DTMF_EVENT_6 = 6, 75 FS_DTMF_EVENT_7 = 7, 76 FS_DTMF_EVENT_8 = 8, 77 FS_DTMF_EVENT_9 = 9, 78 FS_DTMF_EVENT_STAR = 10, 79 FS_DTMF_EVENT_POUND = 11, 80 FS_DTMF_EVENT_A = 12, 81 FS_DTMF_EVENT_B = 13, 82 FS_DTMF_EVENT_C = 14, 83 FS_DTMF_EVENT_D = 15 84 } FsDTMFEvent; 85 86 /** 87 * FsDTMFMethod: 88 * @FS_DTMF_METHOD_RTP_RFC4733: Send as a special payload type defined by RFC 4733 89 * (which obsoletes RFC 2833) 90 * @FS_DTMF_METHOD_SOUND: Send as tones as in-band audio sound 91 * 92 * An enum that represents the different ways a DTMF event can be sent 93 * 94 */ 95 typedef enum _FsDTMFMethod 96 { 97 FS_DTMF_METHOD_RTP_RFC4733 = 1, 98 FS_DTMF_METHOD_SOUND = 2 99 } FsDTMFMethod; 100 101 /** 102 * FsSessionClass: 103 * @parent_class: Our parent 104 * @new_stream: Create a new #FsStream 105 * @start_telephony_event: Starts a telephony event 106 * @stop_telephony_event: Stops a telephony event 107 * @set_send_codec: Forces sending with a specific codec 108 * @set_codec_preferences: Specifies the codec preferences 109 * @list_transmitters: Returns a list of the available transmitters 110 * @get_stream_transmitter_type: Returns the GType of the stream transmitter 111 * @codecs_need_resend: Returns the list of codecs that need resending 112 * @set_allowed_caps: Set the possible allowed src and sink caps 113 * @set_encryption_parameters: Set encryption parameters 114 * 115 * You must override at least new_stream in a subclass. 116 */ 117 118 119 struct _FsSessionClass 120 { 121 GObjectClass parent_class; 122 123 /*virtual functions */ 124 FsStream *(* new_stream) (FsSession *session, 125 FsParticipant *participant, 126 FsStreamDirection direction, 127 GError **error); 128 129 gboolean (* start_telephony_event) (FsSession *session, guint8 event, 130 guint8 volume); 131 gboolean (* stop_telephony_event) (FsSession *session); 132 133 gboolean (* set_send_codec) (FsSession *session, FsCodec *send_codec, 134 GError **error); 135 gboolean (* set_codec_preferences) (FsSession *session, 136 GList *codec_preferences, 137 GError **error); 138 139 gchar** (* list_transmitters) (FsSession *session); 140 141 GType (* get_stream_transmitter_type) (FsSession *session, 142 const gchar *transmitter); 143 144 GList* (* codecs_need_resend) (FsSession *session, GList *old_codecs, 145 GList *new_codecs); 146 147 gboolean (* set_allowed_caps) (FsSession *session, GstCaps *sink_caps, 148 GstCaps *src_caps, GError **error); 149 150 gboolean (* set_encryption_parameters) (FsSession *session, 151 GstStructure *parameters, GError **error); 152 153 /*< private >*/ 154 gpointer _padding[6]; 155 }; 156 157 /** 158 * FsSession: 159 * 160 * All members are private, access them using methods and properties 161 */ 162 struct _FsSession 163 { 164 GObject parent; 165 /*< private >*/ 166 167 FsSessionPrivate *priv; 168 169 170 gpointer _padding[8]; 171 }; 172 173 GType fs_session_get_type (void); 174 175 FsStream *fs_session_new_stream (FsSession *session, 176 FsParticipant *participant, 177 FsStreamDirection direction, 178 GError **error); 179 180 gboolean fs_session_start_telephony_event (FsSession *session, guint8 event, 181 guint8 volume); 182 183 gboolean fs_session_stop_telephony_event (FsSession *session); 184 185 gboolean fs_session_set_send_codec (FsSession *session, FsCodec *send_codec, 186 GError **error); 187 188 gboolean fs_session_set_codec_preferences (FsSession *session, 189 GList *codec_preferences, 190 GError **error); 191 192 gchar **fs_session_list_transmitters (FsSession *session); 193 194 void fs_session_emit_error (FsSession *session, 195 gint error_no, 196 const gchar *error_msg); 197 198 GType fs_session_get_stream_transmitter_type (FsSession *session, 199 const gchar *transmitter); 200 201 GList* fs_session_codecs_need_resend (FsSession *session, 202 GList *old_codecs, GList *new_codecs); 203 204 gboolean fs_session_set_allowed_caps (FsSession *session, GstCaps *sink_caps, 205 GstCaps *src_caps, GError **error); 206 207 gboolean fs_session_set_encryption_parameters (FsSession *session, 208 GstStructure *parameters, GError **error); 209 210 void fs_session_destroy (FsSession *session); 211 212 213 gboolean fs_session_parse_send_codec_changed (FsSession *session, 214 GstMessage *message, 215 FsCodec **codec, 216 GList **secondary_codecs); 217 218 gboolean fs_session_parse_codecs_changed (FsSession *session, 219 GstMessage *message); 220 221 gboolean fs_session_parse_telephony_event_started (FsSession *session, 222 GstMessage *message, 223 FsDTMFMethod *method, 224 FsDTMFEvent *event, 225 guint8 *volume); 226 227 gboolean fs_session_parse_telephony_event_stopped (FsSession *session, 228 GstMessage *message, 229 FsDTMFMethod *method); 230 231 232 G_END_DECLS 233 234 #endif /* __FS_SESSION_H__ */ 235