soa_session.h 8.58 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef SOA_SESSION_H
Pekka Pessi's avatar
Pekka Pessi committed
26
#define SOA_SESSION_H "$Id: soa_session.h,v 1.5 2005/09/28 20:05:24 ppessi Exp $"
Pekka Pessi's avatar
Pekka Pessi committed
27 28 29 30 31
/**@file soa_session.h  Internal API for SDP Offer/Answer Interface.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Mon Aug 1 15:43:53 EEST 2005 ppessi
Pekka Pessi's avatar
Pekka Pessi committed
32
 * $Date: 2005/09/28 20:05:24 $
Pekka Pessi's avatar
Pekka Pessi committed
33 34 35 36 37
 */

#ifndef SOA_H
#include "soa.h"
#endif
38 39 40
#ifndef SOA_TAG_H
#include "soa_tag.h"
#endif
Pekka Pessi's avatar
Pekka Pessi committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#ifndef SDP_H
#include <sdp.h>
#endif
#ifndef SU_STRLST_H
#include <su_strlst.h>
#endif

struct soa_session_actions
{
  int sizeof_soa_session_actions;
  int sizeof_soa_session;
  int (*soa_init)(char const *name, soa_session_t *ss, soa_session_t *parent);
  void (*soa_deinit)(soa_session_t *ss);
  int (*soa_set_params)(soa_session_t *ss, tagi_t const *tags);
  int (*soa_get_params)(soa_session_t const *ss, tagi_t *tags);
56 57
  tagi_t *(*soa_get_paramlist)(soa_session_t const *ss, 
			       tag_type_t, tag_value_t, ...);
Pekka Pessi's avatar
Pekka Pessi committed
58 59 60
  char **(*soa_media_features)(soa_session_t *, int live, su_home_t *);
  char const * const *(*soa_sip_required)(soa_session_t const *ss);
  char const * const *(*soa_sip_support)(soa_session_t const *ss);
Pekka Pessi's avatar
Pekka Pessi committed
61
  int (*soa_remote_sip_features)(soa_session_t *ss,
Pekka Pessi's avatar
Pekka Pessi committed
62 63
				 char const * const * support,
				 char const * const * required);
64 65 66 67
  int (*soa_set_capability_sdp)(soa_session_t *, sdp_session_t *,
				char const *, int);
  int (*soa_set_remote_sdp)(soa_session_t *, int new_version,
			    sdp_session_t *, char const *, int);
68 69
  int (*soa_set_user_sdp)(soa_session_t *, sdp_session_t *,
			  char const *, int);
Pekka Pessi's avatar
Pekka Pessi committed
70 71
  int (*soa_generate_offer)(soa_session_t *ss, soa_callback_f *completed);
  int (*soa_generate_answer)(soa_session_t *ss, soa_callback_f *completed);
72 73
  int (*soa_process_answer)(soa_session_t *ss, soa_callback_f *completed);
  int (*soa_process_reject)(soa_session_t *ss, soa_callback_f *completed);
74 75
  int (*soa_activate_session)(soa_session_t *ss, char const *option);
  int (*soa_deactivate_session)(soa_session_t *ss, char const *option);
Pekka Pessi's avatar
Pekka Pessi committed
76 77 78
  void (*soa_terminate_session)(soa_session_t *ss, char const *option);
};

Pekka Pessi's avatar
Pekka Pessi committed
79 80 81 82 83 84 85
soa_session_t *soa_session_ref(soa_session_t *ss);
void soa_session_unref(soa_session_t *ss);

int soa_base_init(char const *name, soa_session_t *, soa_session_t *parent);
void soa_base_deinit(soa_session_t *ss);
int soa_base_set_params(soa_session_t *ss, tagi_t const *tags);
int soa_base_get_params(soa_session_t const *ss, tagi_t *tags);
86 87
tagi_t *soa_base_get_paramlist(soa_session_t const *ss,
			       tag_type_t, tag_value_t, ...);
Pekka Pessi's avatar
Pekka Pessi committed
88 89 90
char **soa_base_media_features(soa_session_t *, int live, su_home_t *);
char const * const * soa_base_sip_required(soa_session_t const *ss);
char const * const * soa_base_sip_support(soa_session_t const *ss);
91

Pekka Pessi's avatar
Pekka Pessi committed
92
int soa_base_remote_sip_features(soa_session_t *ss,
Pekka Pessi's avatar
Pekka Pessi committed
93 94
				    char const * const * support,
				    char const * const * required);
95
int soa_base_set_capability_sdp(soa_session_t *ss, 
96
				sdp_session_t *sdp, char const *, int);
97 98
int soa_base_set_remote_sdp(soa_session_t *ss, 
			    int new_version,
99 100 101 102
			    sdp_session_t *sdp, char const *, int);
int soa_base_set_user_sdp(soa_session_t *ss,
			  sdp_session_t *sdp, char const *, int);

Pekka Pessi's avatar
Pekka Pessi committed
103 104
int soa_base_generate_offer(soa_session_t *ss, soa_callback_f *completed);
int soa_base_generate_answer(soa_session_t *ss, soa_callback_f *completed);
105 106 107
int soa_base_process_answer(soa_session_t *ss, soa_callback_f *completed);
int soa_base_process_reject(soa_session_t *ss, soa_callback_f *completed);

108 109
int soa_base_activate(soa_session_t *ss, char const *option);
int soa_base_deactivate(soa_session_t *ss, char const *option);
Pekka Pessi's avatar
Pekka Pessi committed
110 111
void soa_base_terminate(soa_session_t *ss, char const *option);

112 113 114 115 116 117 118
struct soa_description 
{
  sdp_session_t  *ssd_sdp;	/**< Session description  */
  char const     *ssd_unparsed;	/**< Original session description as string */
  char const     *ssd_str;	/**< Session description as string */
  sdp_printer_t  *ssd_printer;	/**< SDP printer object */
};
Pekka Pessi's avatar
Pekka Pessi committed
119 120 121 122 123 124

struct soa_session
{
  su_home_t ss_home[1];

  struct soa_session_actions const *ss_actions;
125
  char const *ss_name;		/**< Our name */
Pekka Pessi's avatar
Pekka Pessi committed
126 127

  su_root_t *ss_root;
Pekka Pessi's avatar
Pekka Pessi committed
128
  soa_magic_t *ss_magic;	/**< Application data */
Pekka Pessi's avatar
Pekka Pessi committed
129

Pekka Pessi's avatar
Pekka Pessi committed
130 131 132 133
  soa_callback_f *ss_in_progress;/**< Operation in progress */

  /** Incremented once each time session is terminated */
  unsigned  ss_terminated;
Pekka Pessi's avatar
Pekka Pessi committed
134

Pekka Pessi's avatar
Pekka Pessi committed
135
  unsigned  ss_active:1;	/**< Session has been activated */
Pekka Pessi's avatar
Pekka Pessi committed
136 137 138 139

  /* Current Offer-Answer status */
  unsigned  ss_complete:1;	/**< Completed SDP offer-answer */

140 141
  unsigned  ss_unprocessed_remote:1; /**< We have received remote SDP */

Pekka Pessi's avatar
Pekka Pessi committed
142 143 144 145 146 147 148
  unsigned  ss_offer_sent:2;	/**< We have offered SDP */
  unsigned  ss_answer_recv:2;	/**< We have received SDP answer */

  unsigned  ss_offer_recv:2;	/**< We have received an offer */
  unsigned  ss_answer_sent:2;	/**< We have answered (reliably, if >1) */
  unsigned  :0;			/* Pad */

Pekka Pessi's avatar
Pekka Pessi committed
149
  unsigned  ss_oa_rounds;	/**< Number of O/A rounds completed */
Pekka Pessi's avatar
Pekka Pessi committed
150 151 152

  struct soa_media_activity
  {
153 154 155 156
    int ma_audio:4; /**< Audio activity (send/recv) */
    int ma_video:4; /**< Video activity (send/recv) */
    int ma_image:4; /**< Image activity (send/recv) for JPIP */
    int ma_chat:4;  /**< Chat activity (send/recv) */
Pekka Pessi's avatar
Pekka Pessi committed
157 158
  } ss_local_activity[1], ss_remote_activity[1];

Pekka Pessi's avatar
Pekka Pessi committed
159
  /** Capabilities as specified by application */
160
  struct soa_description ss_caps[1];
161 162 163 164 165

  /** Session description provided by user */
  struct soa_description ss_user[1];
  unsigned ss_user_version;  /**< Version incremented at each change */

166 167
  /** Remote session description */
  struct soa_description ss_remote[1];
168 169 170 171 172
  unsigned ss_remote_version;  /**< Version incremented at each change */

  /** Local session description */
  struct soa_description ss_local[1];
  unsigned ss_local_user_version, ss_local_remote_version;
173
  char const *ss_hold_local;
174 175 176 177

  /** Previous session description (return to this if offer is rejected) */
  struct soa_description ss_previous[1];
  unsigned ss_previous_user_version, ss_previous_remote_version;
178
  char const *ss_hold_previous;
Pekka Pessi's avatar
Pekka Pessi committed
179

180 181
  sdp_session_t *ss_rsession;	/**< Processed remote SDP */

Pekka Pessi's avatar
Pekka Pessi committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
  /** SIP features required */
  char const * const *ss_local_required;
  /** SIP features supported */
  char const * const *ss_local_support;

  /** SIP features required by remote */
  char const **ss_remote_required;
  /** SIP features supported */
  char const **ss_remote_support;

  int             ss_status;	/**< Status from last media operation */
  char const     *ss_phrase;	/**< Phrase from last media operation */
  char const     *ss_warning;	/**< Warnings from last media operation */

  /* Media parameters */
  char const     *ss_address;
  enum soa_af     ss_af;
199
  char const     *ss_hold;	/**< Media on hold locally */
Pekka Pessi's avatar
Pekka Pessi committed
200 201 202

  char const     *ss_cname;

Pekka Pessi's avatar
Pekka Pessi committed
203 204
  unsigned ss_srtp_enable:1,
    ss_srtp_confidentiality:1,
Pekka Pessi's avatar
Pekka Pessi committed
205 206 207
    ss_srtp_integrity:1;
};

Pekka Pessi's avatar
Pekka Pessi committed
208 209
/* ====================================================================== */

Pekka Pessi's avatar
Pekka Pessi committed
210 211
int soa_has_received_sdp(soa_session_t const *ss);

Pekka Pessi's avatar
Pekka Pessi committed
212
int soa_set_status(soa_session_t *ss, int status, char const *phrase);
Pekka Pessi's avatar
Pekka Pessi committed
213

Pekka Pessi's avatar
Pekka Pessi committed
214 215
void soa_set_activity(soa_session_t *ss, sdp_media_t const *m, int remote);

216 217 218
int soa_set_user_sdp(soa_session_t *ss,
		     struct sdp_session_s const *sdp,
		     char const *str, int len);
219 220 221 222 223 224 225 226 227 228 229 230 231

int soa_description_set(soa_session_t *ss, 
			struct soa_description *ssd,
			sdp_session_t *sdp,
			char const *sdp_str,
			int sdp_len);

void soa_description_free(soa_session_t *, struct soa_description *ssd);

int soa_description_dup(su_home_t *, 
			struct soa_description *ssd,
			struct soa_description const *ssd0);

Pekka Pessi's avatar
Pekka Pessi committed
232 233 234
int soa_init_sdp_origin(soa_session_t *ss, sdp_origin_t *o, char buf[64]);
int soa_init_sdp_connection(soa_session_t *, sdp_connection_t *, char buf[64]);

Pekka Pessi's avatar
Pekka Pessi committed
235 236 237 238 239 240 241 242 243 244 245 246
/* ====================================================================== */
/* Debug log settings */

#define SU_LOG   soa_log

#ifdef SU_DEBUG_H
#error <su_debug.h> included directly.
#endif
#include <su_debug.h>
extern su_log_t soa_log[];

#endif