1 /*
2  * sip-media-session.h - Header for SIPMediaSession
3  * Copyright (C) 2005 Collabora Ltd.
4  * Copyright (C) 2005 Nokia Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * version 2.1 as published by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef __SIP_MEDIA_SESSION_H__
21 #define __SIP_MEDIA_SESSION_H__
22 
23 #include <glib-object.h>
24 #include <telepathy-glib/handle.h>
25 #include <sofia-sip/sdp.h>
26 
27 G_BEGIN_DECLS
28 
29 typedef enum {
30     SIP_MEDIA_SESSION_STATE_CREATED = 0,
31     SIP_MEDIA_SESSION_STATE_INVITE_SENT,
32     SIP_MEDIA_SESSION_STATE_INVITE_RECEIVED,
33     SIP_MEDIA_SESSION_STATE_RESPONSE_RECEIVED,
34     SIP_MEDIA_SESSION_STATE_ACTIVE,
35     SIP_MEDIA_SESSION_STATE_REINVITE_SENT,
36     SIP_MEDIA_SESSION_STATE_REINVITE_RECEIVED,
37     SIP_MEDIA_SESSION_STATE_ENDED
38 } SIPMediaSessionState;
39 
40 typedef struct _SIPMediaSession SIPMediaSession;
41 typedef struct _SIPMediaSessionClass SIPMediaSessionClass;
42 
43 struct _SIPMediaSessionClass {
44     GObjectClass parent_class;
45 };
46 
47 struct _SIPMediaSession {
48     GObject parent;
49 };
50 
51 GType sip_media_session_get_type(void);
52 
53 /* TYPE MACROS */
54 #define SIP_TYPE_MEDIA_SESSION \
55   (sip_media_session_get_type())
56 #define SIP_MEDIA_SESSION(obj) \
57   (G_TYPE_CHECK_INSTANCE_CAST((obj), SIP_TYPE_MEDIA_SESSION, SIPMediaSession))
58 #define SIP_MEDIA_SESSION_CLASS(klass) \
59   (G_TYPE_CHECK_CLASS_CAST((klass), SIP_TYPE_MEDIA_SESSION, SIPMediaSessionClass))
60 #define SIP_IS_MEDIA_SESSION(obj) \
61   (G_TYPE_CHECK_INSTANCE_TYPE((obj), SIP_TYPE_MEDIA_SESSION))
62 #define SIP_IS_MEDIA_SESSION_CLASS(klass) \
63   (G_TYPE_CHECK_CLASS_TYPE((klass), SIP_TYPE_MEDIA_SESSION))
64 #define SIP_MEDIA_SESSION_GET_CLASS(obj) \
65   (G_TYPE_INSTANCE_GET_CLASS ((obj), SIP_TYPE_MEDIA_SESSION, SIPMediaSessionClass))
66 
67 /***********************************************************************
68  * Additional declarations (not based on generated templates)
69  ***********************************************************************/
70 
71 /* Telepathy type helpers */
72 #define SIP_TP_STREAM_LIST_TYPE (sip_tp_stream_list_type ())
73 GType sip_tp_stream_list_type (void) G_GNUC_CONST;
74 
75 TpHandle sip_media_session_get_peer (SIPMediaSession *session);
76 void sip_media_session_terminate (SIPMediaSession *session);
77 gboolean sip_media_session_set_remote_media (SIPMediaSession *chan,
78                                             const sdp_session_t* r_sdp);
79 gboolean sip_media_session_request_streams (SIPMediaSession *session,
80 					    const GArray *media_types,
81 					    GPtrArray **ret,
82 					    GError **error);
83 gboolean sip_media_session_remove_streams (SIPMediaSession *session,
84                                            const GArray *stream_ids,
85                                            GError **error);
86 gboolean sip_media_session_list_streams (SIPMediaSession *session,
87 					 GPtrArray **ret);
88 gboolean sip_media_session_request_stream_direction (SIPMediaSession *session,
89                                                      guint stream_id,
90                                                      guint direction,
91                                                      GError **error);
92 void sip_media_session_receive_invite (SIPMediaSession *self);
93 void sip_media_session_receive_reinvite (SIPMediaSession *self);
94 void sip_media_session_accept (SIPMediaSession *self);
95 void sip_media_session_reject (SIPMediaSession *self,
96                                gint status,
97                                const char *message);
98 gboolean sip_media_session_start_telephony_event (SIPMediaSession *self,
99                                                   guint stream_id,
100                                                   guchar event,
101                                                   GError **error);
102 gboolean sip_media_session_stop_telephony_event  (SIPMediaSession *self,
103                                                   guint stream_id,
104                                                   GError **error);
105 
106 gint sip_media_session_rate_native_transport (SIPMediaSession *session,
107                                               const GValue *transport);
108 
109 #ifdef ENABLE_DEBUG
110 
111 #define SESSION_DEBUG(s, ...)    sip_media_session_debug (s, __VA_ARGS__)
112 
113 void sip_media_session_debug (SIPMediaSession *session,
114 			      const gchar *format, ...);
115 
116 #else
117 
118 #define SESSION_DEBUG(s, ...)
119 
120 #endif
121 
122 G_END_DECLS
123 
124 #endif /* #ifndef __SIP_MEDIA_SESSION_H__*/
125