telepathygabble/inc/gabble-media-session.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /*
       
     2  * gabble-media-session.h - Header for GabbleMediaSession
       
     3  * Copyright (C) 2006 Collabora Ltd.
       
     4  * Portions 
       
     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
       
     8  * License as published by the Free Software Foundation; either
       
     9  * version 2.1 of the License, or (at your option) any later version.
       
    10  *
       
    11  * This library is distributed in the hope that it will be useful,
       
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    14  * Lesser General Public License for more details.
       
    15  *
       
    16  * You should have received a copy of the GNU Lesser General Public
       
    17  * License along with this library; if not, write to the Free Software
       
    18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    19  */
       
    20 
       
    21 #ifndef __GABBLE_MEDIA_SESSION_H__
       
    22 #define __GABBLE_MEDIA_SESSION_H__
       
    23 
       
    24 #include <glib-object.h>
       
    25 #include "loudmouth/loudmouth.h"
       
    26 
       
    27 #include "gabble-types.h"
       
    28 #include "gabble-media-stream.h"
       
    29 #include "telepathy-constants.h"
       
    30 
       
    31 G_BEGIN_DECLS
       
    32 
       
    33 
       
    34 typedef enum
       
    35 {
       
    36   MODE_GOOGLE,
       
    37   MODE_JINGLE
       
    38 } GabbleMediaSessionMode;
       
    39 
       
    40 typedef enum {
       
    41     JS_STATE_INVALID = -1,
       
    42     JS_STATE_PENDING_CREATED = 0,
       
    43     JS_STATE_PENDING_INITIATE_SENT,
       
    44     JS_STATE_PENDING_INITIATED,
       
    45     JS_STATE_PENDING_ACCEPT_SENT,
       
    46     JS_STATE_ACTIVE,
       
    47     JS_STATE_ENDED
       
    48 } JingleSessionState;
       
    49 
       
    50 typedef enum {
       
    51     DEBUG_MSG_INFO = 0,
       
    52     DEBUG_MSG_DUMP,
       
    53     DEBUG_MSG_WARNING,
       
    54     DEBUG_MSG_ERROR,
       
    55     DEBUG_MSG_EVENT
       
    56 } DebugMessageType;
       
    57 
       
    58 typedef struct _GabbleMediaSession GabbleMediaSession;
       
    59 typedef struct _GabbleMediaSessionClass GabbleMediaSessionClass;
       
    60 
       
    61 struct _GabbleMediaSessionClass {
       
    62     GObjectClass parent_class;
       
    63 };
       
    64 
       
    65 struct _GabbleMediaSession {
       
    66     GObject parent;
       
    67 
       
    68     JingleInitiator initiator;
       
    69 
       
    70     gpointer priv;
       
    71 };
       
    72 
       
    73 IMPORT_C GType gabble_media_session_get_type(void);
       
    74 
       
    75 /* TYPE MACROS */
       
    76 #define GABBLE_TYPE_MEDIA_SESSION \
       
    77   (gabble_media_session_get_type())
       
    78 #define GABBLE_MEDIA_SESSION(obj) \
       
    79   (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSession))
       
    80 #define GABBLE_MEDIA_SESSION_CLASS(klass) \
       
    81   (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSessionClass))
       
    82 #define GABBLE_IS_MEDIA_SESSION(obj) \
       
    83   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_MEDIA_SESSION))
       
    84 #define GABBLE_IS_MEDIA_SESSION_CLASS(klass) \
       
    85   (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_MEDIA_SESSION))
       
    86 #define GABBLE_MEDIA_SESSION_GET_CLASS(obj) \
       
    87   (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_SESSION, GabbleMediaSessionClass))
       
    88 
       
    89 #define NODE_DEBUG(n, s)
       
    90 
       
    91 /* CONVENIENCE MACROS */
       
    92 #define MSG_REPLY_CB_END_SESSION_IF_NOT_SUCCESSFUL(s, m) \
       
    93   G_STMT_START { \
       
    94   if (lm_message_get_sub_type (reply_msg) != LM_MESSAGE_SUB_TYPE_RESULT) \
       
    95     { \
       
    96       _gabble_media_session_debug (s, DEBUG_MSG_ERROR, m); \
       
    97       NODE_DEBUG (sent_msg->node, "message sent"); \
       
    98       NODE_DEBUG (reply_msg->node, "message reply"); \
       
    99       _gabble_media_session_terminate (s, INITIATOR_LOCAL, TP_CHANNEL_GROUP_CHANGE_REASON_ERROR); \
       
   100       return LM_HANDLER_RESULT_REMOVE_MESSAGE; \
       
   101     } \
       
   102   } G_STMT_END
       
   103 
       
   104 gboolean
       
   105 gabble_media_session_error (GabbleMediaSession *self,
       
   106                             guint errno,
       
   107                             const gchar *message,
       
   108                             GError **error);
       
   109 
       
   110 gboolean
       
   111 gabble_media_session_ready (GabbleMediaSession *self,
       
   112                             GError **error);
       
   113 
       
   114 
       
   115 gboolean
       
   116 _gabble_media_session_handle_action (GabbleMediaSession *session,
       
   117                                      LmMessage *message,
       
   118                                      LmMessageNode *session_node,
       
   119                                      const gchar *action,
       
   120                                      GError **error);
       
   121 
       
   122 LmMessage *_gabble_media_session_message_new (GabbleMediaSession *session,
       
   123                                               const gchar *action,
       
   124                                               LmMessageNode **session_node);
       
   125 
       
   126 void _gabble_media_session_accept (GabbleMediaSession *session);
       
   127 void _gabble_media_session_remove_streams (GabbleMediaSession *session, GabbleMediaStream **streams, guint len);
       
   128 void _gabble_media_session_terminate (GabbleMediaSession *session, JingleInitiator who, TpChannelGroupChangeReason why);
       
   129 
       
   130 gboolean _gabble_media_session_request_streams (GabbleMediaSession *session,
       
   131                                                 const GArray *types,
       
   132                                                 GPtrArray **ret,
       
   133                                                 GError **error);
       
   134 
       
   135 gboolean _gabble_media_session_request_stream_direction (GabbleMediaSession *,
       
   136                                                          GabbleMediaStream *,
       
   137                                                          TpMediaStreamDirection,
       
   138                                                          GError **);
       
   139 
       
   140 #ifndef _GMS_DEBUG_LEVEL
       
   141 #define _GMS_DEBUG_LEVEL 2
       
   142 #endif
       
   143 
       
   144 #if _GMS_DEBUG_LEVEL
       
   145 #ifdef ENABLE_DEBUG
       
   146 
       
   147 //#define GMS_DEBUG_INFO(s, ...)    _gabble_media_session_debug (s, DEBUG_MSG_INFO, __VA_ARGS__)
       
   148 //vinod
       
   149 #define GMS_DEBUG_INFO G_GMS_DEBUG_INFO
       
   150 	static inline void G_GMS_DEBUG_INFO (const gchar *s, ...)
       
   151 	{
       
   152 	_gabble_media_session_debug (s, DEBUG_MSG_INFO, __VA_ARGS__)	
       
   153 	}
       
   154 
       
   155 
       
   156 #if _GMS_DEBUG_LEVEL > 1
       
   157 //#define GMS_DEBUG_DUMP(s, ...)    _gabble_media_session_debug (s, DEBUG_MSG_DUMP, __VA_ARGS__)
       
   158 //vinod
       
   159 #define GMS_DEBUG_DUMP G_GMS_DEBUG_DUMP
       
   160 	static inline void G_GMS_DEBUG_DUMP (const gchar *s, ...)
       
   161 	{
       
   162 	_gabble_media_session_debug (s, DEBUG_MSG_DUMP, __VA_ARGS__)	
       
   163 	}
       
   164 	
       
   165 #else
       
   166 #define GMS_DEBUG_DUMP(s, ...)
       
   167 #endif
       
   168 //#define GMS_DEBUG_WARNING(s, ...) _gabble_media_session_debug (s, DEBUG_MSG_WARNING, __VA_ARGS__)
       
   169 //vinod
       
   170 #define GMS_DEBUG_WARNING G_GMS_DEBUG_WARNING
       
   171 	static inline void G_GMS_DEBUG_WARNING (const gchar *s, ...)
       
   172 	{
       
   173 	_gabble_media_session_debug (s, DEBUG_MSG_WARNING, __VA_ARGS__)
       
   174 	}
       
   175 
       
   176 //#define GMS_DEBUG_ERROR(s, ...)   _gabble_media_session_debug (s, DEBUG_MSG_ERROR, __VA_ARGS__)
       
   177 //vinod
       
   178 #define GMS_DEBUG_ERROR G_GMS_DEBUG_ERROR
       
   179 	static inline void G_GMS_DEBUG_ERROR (const gchar *s, ...)
       
   180 	{
       
   181 	_gabble_media_session_debug (s, DEBUG_MSG_ERROR, __VA_ARGS__)	
       
   182 	}
       
   183 
       
   184 
       
   185 //#define GMS_DEBUG_EVENT(s, ...)   _gabble_media_session_debug (s, DEBUG_MSG_EVENT, __VA_ARGS__)
       
   186 //vinod
       
   187 #define GMS_DEBUG_EVENT G_GMS_DEBUG_EVENT
       
   188 	static inline void G_GMS_DEBUG_EVENT (const gchar *s, ...)
       
   189 	{
       
   190 	_gabble_media_session_debug (s, DEBUG_MSG_EVENT, __VA_ARGS__)	
       
   191 	}
       
   192 
       
   193 void _gabble_media_session_debug (GabbleMediaSession *session,
       
   194                                   DebugMessageType type,
       
   195                                   const gchar *format, ...)
       
   196     G_GNUC_PRINTF (3, 4);
       
   197 
       
   198 #else
       
   199 
       
   200 void _gabble_media_session_debug (GabbleMediaSession *session,
       
   201                                   DebugMessageType type,
       
   202                                   const gchar *format, ...)
       
   203     G_GNUC_PRINTF (3, 4);
       
   204 
       
   205 //#define GMS_DEBUG_INFO(s, ...)
       
   206 #define GMS_DEBUG_INFO
       
   207 //#define GMS_DEBUG_DUMP(s, ...)
       
   208 #define GMS_DEBUG_DUMP
       
   209 //#define GMS_DEBUG_WARNING(s, ...)
       
   210 #define GMS_DEBUG_WARNING
       
   211 //#define GMS_DEBUG_ERROR(s, ...)
       
   212 #define GMS_DEBUG_ERROR
       
   213 //#define GMS_DEBUG_EVENT(s, ...)
       
   214 #define GMS_DEBUG_EVENT
       
   215 
       
   216 #endif /* ENABLE_DEBUG */
       
   217 #endif /* _GMS_DEBUG_LEVEL */
       
   218 
       
   219 G_END_DECLS
       
   220 
       
   221 #endif /* #ifndef __GABBLE_MEDIA_SESSION_H__*/