sdp.h 19.3 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 * 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 SDP_H
Pekka Pessi's avatar
Pekka Pessi committed
26
#define SDP_H
Pekka Pessi's avatar
Pekka Pessi committed
27
/**@file sofia-sip/sdp.h  Simple SDP (RFC 2327) Interface.
Pekka Pessi's avatar
Pekka Pessi committed
28 29 30 31 32 33 34 35
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * @author Kai Vehmanen <kai.vehmanen@nokia.com>
 *
 * @date Created: Fri Feb 18 08:54:48 2000 ppessi
 */

#ifndef SU_ALLOC_H
36
#include <sofia-sip/su_alloc.h>
Pekka Pessi's avatar
Pekka Pessi committed
37 38
#endif
#ifndef SU_TYPES_H
39
#include <sofia-sip/su_types.h>
Pekka Pessi's avatar
Pekka Pessi committed
40 41
#endif

42 43
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/** SDP session description */
typedef struct sdp_session_s     sdp_session_t;
/** SDP version "v=" line */
typedef unsigned long            sdp_version_t;
/** SDP origin "o=" line */
typedef struct sdp_origin_s      sdp_origin_t;
/** SDP connection "c=" line */
typedef struct sdp_connection_s  sdp_connection_t;
/** SDP bandwidth "b=" line */
typedef struct sdp_bandwidth_s   sdp_bandwidth_t;
/** SDP time "t=" line */
typedef struct sdp_time_s        sdp_time_t;
/** SDP repeat "r=" line */
typedef struct sdp_repeat_s      sdp_repeat_t;
/** SDP timezone "z=" line */
typedef struct sdp_zone_s        sdp_zone_t;
/** SDP encryption key "k=" line */
typedef struct sdp_key_s         sdp_key_t;
/** SDP attribute "a=" line */
typedef struct sdp_attribute_s   sdp_attribute_t;
/** SDP media "m=" line */
typedef struct sdp_media_s       sdp_media_t;
/** SDP list ("e=", "p=" lines) */
typedef struct sdp_list_s        sdp_list_t;
/** SDP rtpmap attribute */
typedef struct sdp_rtpmap_s      sdp_rtpmap_t;

/** Message text */
72
typedef char const               sdp_text_t;
Pekka Pessi's avatar
Pekka Pessi committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231

#define SDP_MIME_TYPE "application/sdp"

enum {
  SDP_CURRENT_VERSION = 0
};

/** Session description */
struct sdp_session_s
{
  int                sdp_size;		/**< sizeof sdp_session_t */
  sdp_session_t     *sdp_next;	        /**< Next description in list */
  sdp_version_t      sdp_version[1];	/**< SDP version */
  sdp_origin_t      *sdp_origin;	/**< Owner/creator and session ID */
  sdp_text_t        *sdp_subject;	/**< Session name */
  sdp_text_t        *sdp_information;	/**< Session information  */
  sdp_text_t        *sdp_uri;		/**< URi of description */
  sdp_list_t   	    *sdp_emails;	/**< E-mail address(s) */
  sdp_list_t   	    *sdp_phones;	/**< Phone number(s)  */
  sdp_connection_t  *sdp_connection;	/**< Group (or member) address */
  sdp_bandwidth_t   *sdp_bandwidths;	/**< Session bandwidth */
  sdp_time_t        *sdp_time;		/**< Session active time */
  sdp_key_t         *sdp_key;	        /**< Session key */
  sdp_attribute_t   *sdp_attributes;    /**< Session attributes */
  sdp_text_t        *sdp_charset;       /**< SDP charset (default is UTF8) */
  sdp_media_t       *sdp_media;         /**< Media descriptors */
};

/** Session description identification */ 
struct sdp_origin_s
{
  int               o_size;		/**< sizeof sdp_origin_t */
  sdp_text_t       *o_username;		/**< Username of originator */
  uint64_t          o_id;		/**< Session identification  */
  uint64_t          o_version;		/**< Version of session description */
  sdp_connection_t *o_address;		/**< Address of originator */
};

/** Network type */
typedef enum
{
  sdp_net_x = 0,			/**< Unknown network type */
  sdp_net_in = 1		        /**< Internet */
} sdp_nettype_e;

/** Address type */
typedef enum
{
  sdp_addr_x   = 0,			/**< Unknown address type */
  sdp_addr_ip4 = 1,			/**< IPv4 address */
  sdp_addr_ip6 = 2,			/**< IPv6 address */
} sdp_addrtype_e;

/** SDP connection - host or group address */
struct sdp_connection_s
{
  int               c_size;		/**< Size fo sdp_connection_t */
  sdp_connection_t *c_next;		/**< Next connection in list */
  sdp_nettype_e     c_nettype;		/**< Network type */
  sdp_addrtype_e    c_addrtype;		/**< Address type */
  sdp_text_t       *c_address;		/**< Host or group address */
  unsigned          c_ttl : 8;		/**< Time to live (scope) */
  unsigned          c_mcast : 1;        /**< True if multicast */
  unsigned : 0;
  unsigned          c_groups;		/**< Number of groups (if multiple) */
};

/** Bandwdith type */
typedef enum
{
  sdp_bw_x,				/**< Unknown bandwidth type */
  sdp_bw_ct,				/**< Conference total */
  sdp_bw_as,				/**< Application-specific */
} sdp_bandwidth_e;

/** Session or media bandwidth. */
struct sdp_bandwidth_s
{
  int              b_size;		/**< Size fo sdp_bandwidth_t */
  sdp_bandwidth_t *b_next;		/**< Next bw description in list */
  sdp_bandwidth_e  b_modifier;		/**< Meaning of value 
					     (total, or per application).  */
  sdp_text_t      *b_modifier_name;     /**< Modifier if not well-known */
  unsigned long    b_value;		/**< Bandwidth in kilobits per second */
};

/** Active time description. */
struct sdp_time_s
{
  int            t_size;		/**< sizeof sdp_time_t in bytes */
  sdp_time_t    *t_next;		/**< Next time description in list */
  unsigned long  t_start;		/**< Start time (seconds since 1900) */
  unsigned long  t_stop;		/**< Stop time (seconds since 1900) */
  sdp_repeat_t  *t_repeat;		/**< Repeat information */
  sdp_zone_t    *t_zone;		/**< Time Zone infromation */
};

/** Description of repetition. */
struct sdp_repeat_s
{
  int           r_size;			/**< Size of structure including
					 * r_offsets[r_number_of_offsets]
					 */
  int           r_number_of_offsets;	/**< Number of offsets in list */
  unsigned long r_interval;		/**< Time between activations */
  unsigned long r_duration;		/**< Duration of activation */
  unsigned long r_offsets[1];	        /**< List of offsets from start-time */
};

/** Timezone */
struct sdp_zone_s
{
  /** Size of structure including z_adjustments[z_number_of_adjustments] */
  int z_size;
  int z_number_of_adjustments;		/**< Number of adjustments in list  */
  struct {
    unsigned long z_at;			/**< Adjustment time  */
    long          z_offset;		/**< Adjustment offset  */
  } z_adjustments[1];		        /**< List of timezone adjustments */
};

/** Mechanism to be used to obtain session key */
typedef enum {
  sdp_key_x,				/**< Unknown mechanism */
  sdp_key_clear,			/**< Key is included untransformed */
  sdp_key_base64,			/**< Key is encoded with base64 */
  sdp_key_uri,				/**< URI used to obtain a key */
  sdp_key_prompt			/**< No key is included, 
					     prompt user for key */
} sdp_key_method_e;

/** Session key */
struct sdp_key_s
{
  int              k_size;		/**< sizeof sdp_key_t  */
  sdp_key_method_e k_method;		/**< Mechanism used to obtain key */
  sdp_text_t      *k_method_name;	/**< Mechanism if not known  */
  sdp_text_t      *k_material;		/**< Encryption key  */
};

/** Session or media attribute */
struct sdp_attribute_s {
  int              a_size;		/**< sizeof sdp_attribute_t  */
  sdp_attribute_t *a_next;		/**< Next attribute in list */
  sdp_text_t      *a_name;		/**< Attribute name */
  sdp_text_t      *a_value;		/**< Attribute value */
};

/** Media type @sa RFC2327 page 18. */
typedef enum
{
  sdp_media_x = 0,			/**< Unknown media */
  sdp_media_any,		        /**< * wildcard */
  sdp_media_audio,			/**< Audio */
  sdp_media_video,			/**< Video */
  sdp_media_application,		/**< Conferencing */
  sdp_media_data,			/**< Bulk data transfer */
  sdp_media_control,			/**< Additional conference control */
  sdp_media_message,			/**< Messaging sessions*/
232 233
  sdp_media_image,			/**< Image browsing sessions for JPIP, and T.38 */
  sdp_media_red				/**< Redundancy */
Pekka Pessi's avatar
Pekka Pessi committed
234 235 236 237 238 239 240 241 242 243
} sdp_media_e;

/** Media transport protocol. */
typedef enum
{
  sdp_proto_x = 0,			/**< Unknown transport  */
  sdp_proto_tcp = 6,			/**< TCP  */
  sdp_proto_udp = 17,			/**< Plain UDP */
  sdp_proto_rtp = 256,			/**< RTP/AVP */
  sdp_proto_srtp = 257,			/**< RTP/SAVP  */
244
  sdp_proto_udptl = 258,			/**< UDPTL  */
Pekka Pessi's avatar
Pekka Pessi committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
  sdp_proto_tls = 511,			/**< TLS over TCP */
  sdp_proto_any = 512		        /**< * wildcard */
} sdp_proto_e;

/** Session mode. @note Identical to rtp_mode_t. */
typedef enum {
  sdp_inactive = 0, 
  sdp_sendonly = 1, 
  sdp_recvonly = 2, 
  sdp_sendrecv = sdp_sendonly | sdp_recvonly
} sdp_mode_t;

/** Media announcement.
 * 
 * This structure describes one media type, e.g., audio.  The description
 * contains the transport address (IP address and port) used for the group,
 * the transport protocol used, the media formats or RTP payload types, and
 * optionally media-specific bandwidth specification, encryption key and
 * attributes. 
 *
 * There is a pointer (m_user) for the application data, too.
 */
struct sdp_media_s
{
  int               m_size;		/**< sizeof sdp_media_t  */
  sdp_media_t      *m_next;		/**< Next media announcement  */
  sdp_session_t    *m_session;          /**< Back-pointer to session level */

  sdp_media_e       m_type;		/**< Media type  */
  sdp_text_t       *m_type_name;	/**< Media type name */
  unsigned long     m_port;		/**< Transport port number */
  unsigned long     m_number_of_ports;	/**< Number of ports (if multiple) */
  sdp_proto_e       m_proto;		/**< Transport protocol  */
  sdp_text_t       *m_proto_name;	/**< Transport protocol name */
  sdp_list_t       *m_format;		/**< List of media formats */
  sdp_rtpmap_t     *m_rtpmaps;		/**< List of RTP maps */
  sdp_text_t       *m_information;	/**< Media information */
  sdp_connection_t *m_connections;	/**< List of addresses used */
  sdp_bandwidth_t  *m_bandwidths;	/**< Bandwidth specification */
  sdp_key_t        *m_key;		/**< Media key */
  sdp_attribute_t  *m_attributes;	/**< Media attributes */

  void             *m_user;	        /**< User data. */
288
  
Pekka Pessi's avatar
Pekka Pessi committed
289 290 291
  /** Rejected media */
  unsigned          m_rejected : 1;     
  /** Inactive, recvonly, sendonly, sendrecv */
292
  /* sdp_mode_t */ unsigned m_mode : 2;
Pekka Pessi's avatar
Pekka Pessi committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
  unsigned          : 0;
};

/** Text list */
struct sdp_list_s
{
  int              l_size;		/**< sizeof sdp_list_t  */
  sdp_list_t      *l_next;		/**< Next text entry in list */
  sdp_text_t      *l_text;	        /**< Text as C string */
};

/** Mapping from RTP payload to codec.
 * 
 * The sdp_rtpmap_t() structure defines a mapping from an RTP payload to a
 * particular codec.  In case of well-known payloads, the sdp_rtpmap_t()
 * structure may be predefined, that is, generated by SDP parser without
 * corresponding "a" line in the SDP.  The sdp_rtpmap_t() structure may also
 * contain the @c fmtp attribute, which is used to convey format-specific
 * parameters.
 */
struct sdp_rtpmap_s {
  int            rm_size;		/**< sizeof sdp_rtpmap_t  */
  sdp_rtpmap_t  *rm_next;		/**< Next RTP map entry  */
  sdp_text_t    *rm_encoding;		/**< Codec name */
  unsigned long  rm_rate;		/**< Sampling rate */
  sdp_text_t    *rm_params;		/**< Format-specific parameters  */
  sdp_text_t    *rm_fmtp;	        /**< Contents of fmtp */
320 321 322 323
  unsigned       rm_predef : 1;	        /**< is this entry well-known? */
  unsigned       rm_pt : 7;		/**< Payload type */
  unsigned       rm_any : 1;	        /**< Wildcard entry */
  int       :0;
Pekka Pessi's avatar
Pekka Pessi committed
324 325
};

Pekka Pessi's avatar
Pekka Pessi committed
326
SOFIAPUBVAR sdp_rtpmap_t const * const sdp_rtpmap_well_known[128];
327

Pekka Pessi's avatar
Pekka Pessi committed
328
/** Duplicate an SDP session description structure. */
Pekka Pessi's avatar
Pekka Pessi committed
329
SOFIAPUBFUN sdp_session_t *sdp_session_dup(su_home_t *, sdp_session_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
330 331

/** Duplicate an SDP origin structure. */
Pekka Pessi's avatar
Pekka Pessi committed
332 333 334
SOFIAPUBFUN
sdp_origin_t    *sdp_origin_dup(su_home_t *, sdp_origin_t const *);

Pekka Pessi's avatar
Pekka Pessi committed
335
/** Duplicate an SDP connection structure. */
Pekka Pessi's avatar
Pekka Pessi committed
336
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
337
sdp_connection_t *sdp_connection_dup(su_home_t *home, sdp_connection_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
338

Pekka Pessi's avatar
Pekka Pessi committed
339
/** Duplicate an SDP bandwidth structure. */
Pekka Pessi's avatar
Pekka Pessi committed
340
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
341
sdp_bandwidth_t  *sdp_bandwidth_dup(su_home_t *home, sdp_bandwidth_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
342

Pekka Pessi's avatar
Pekka Pessi committed
343
/** Duplicate an SDP time structure. */
Pekka Pessi's avatar
Pekka Pessi committed
344
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
345
sdp_time_t       *sdp_time_dup(su_home_t *home, sdp_time_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
346

Pekka Pessi's avatar
Pekka Pessi committed
347
/** Duplicate an SDP repeat structure. */
Pekka Pessi's avatar
Pekka Pessi committed
348
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
349
sdp_repeat_t     *sdp_repeat_dup(su_home_t *home, sdp_repeat_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
350

Pekka Pessi's avatar
Pekka Pessi committed
351
/** Duplicate an SDP timezone structure. */
Pekka Pessi's avatar
Pekka Pessi committed
352
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
353
sdp_zone_t       *sdp_zone_dup(su_home_t *home, sdp_zone_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
354

Pekka Pessi's avatar
Pekka Pessi committed
355
/** Duplicate an SDP key structure. */
Pekka Pessi's avatar
Pekka Pessi committed
356
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
357
sdp_key_t        *sdp_key_dup(su_home_t *home, sdp_key_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
358

Pekka Pessi's avatar
Pekka Pessi committed
359
/** Duplicate an SDP attribute structure. */
Pekka Pessi's avatar
Pekka Pessi committed
360
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
361
sdp_attribute_t  *sdp_attribute_dup(su_home_t *home, sdp_attribute_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
362

Pekka Pessi's avatar
Pekka Pessi committed
363
/** Duplicate an SDP media description structure. */
Pekka Pessi's avatar
Pekka Pessi committed
364 365 366 367
SOFIAPUBFUN
sdp_media_t *sdp_media_dup(su_home_t *, sdp_media_t const *,
			   sdp_session_t *);

Pekka Pessi's avatar
Pekka Pessi committed
368
/** Duplicate a list of SDP media description structures. */
Pekka Pessi's avatar
Pekka Pessi committed
369 370 371 372
SOFIAPUBFUN
sdp_media_t *sdp_media_dup_all(su_home_t *, sdp_media_t const *,
			       sdp_session_t *);

Pekka Pessi's avatar
Pekka Pessi committed
373
/** Duplicate a list structure. */
Pekka Pessi's avatar
Pekka Pessi committed
374
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
375
sdp_list_t       *sdp_list_dup(su_home_t *home, sdp_list_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
376

Pekka Pessi's avatar
Pekka Pessi committed
377
/** Duplicate an rtpmap structure. */
Pekka Pessi's avatar
Pekka Pessi committed
378
SOFIAPUBFUN
Pekka Pessi's avatar
Pekka Pessi committed
379 380
sdp_rtpmap_t     *sdp_rtpmap_dup(su_home_t *home, sdp_rtpmap_t const *);

381
/** Compare two session descriptions. */
Pekka Pessi's avatar
Pekka Pessi committed
382 383
SOFIAPUBFUN int sdp_session_cmp(sdp_session_t const *a,
				sdp_session_t const *b);
384

Pekka Pessi's avatar
Pekka Pessi committed
385
/** Compare two origin fields */
Pekka Pessi's avatar
Pekka Pessi committed
386 387
SOFIAPUBFUN int sdp_origin_cmp(sdp_origin_t const *a,
			       sdp_origin_t const *b);
Pekka Pessi's avatar
Pekka Pessi committed
388

389
/** Compare two connection fields */
Pekka Pessi's avatar
Pekka Pessi committed
390 391
SOFIAPUBFUN int sdp_connection_cmp(sdp_connection_t const *,
				   sdp_connection_t const *b);
392 393

/** Compare two bandwidth (b=) fields */
Pekka Pessi's avatar
Pekka Pessi committed
394 395
SOFIAPUBFUN int sdp_bandwidth_cmp(sdp_bandwidth_t const *a,
				  sdp_bandwidth_t const *b);
396

Pekka Pessi's avatar
Pekka Pessi committed
397
/** Compare two time fields */
Pekka Pessi's avatar
Pekka Pessi committed
398
SOFIAPUBFUN int sdp_time_cmp(sdp_time_t const *a, sdp_time_t const *b);
Pekka Pessi's avatar
Pekka Pessi committed
399 400

/* Compare two repeat (r=) fields */
Pekka Pessi's avatar
Pekka Pessi committed
401
SOFIAPUBFUN int sdp_repeat_cmp(sdp_repeat_t const *a, sdp_repeat_t const *b);
402

Pekka Pessi's avatar
Pekka Pessi committed
403
/* Compare two zone (z=) fields */
Pekka Pessi's avatar
Pekka Pessi committed
404
SOFIAPUBFUN int sdp_zone_cmp(sdp_zone_t const *a, sdp_zone_t const *b);
Pekka Pessi's avatar
Pekka Pessi committed
405

406
/** Compare two key (k=) fields. */
Pekka Pessi's avatar
Pekka Pessi committed
407
SOFIAPUBFUN int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b);
408 409

/** Compare two attribute (a=) fields */
Pekka Pessi's avatar
Pekka Pessi committed
410 411
SOFIAPUBFUN int sdp_attribute_cmp(sdp_attribute_t const *,
				  sdp_attribute_t const *);
412

Pekka Pessi's avatar
Pekka Pessi committed
413
/** Compare two media (m=) descriptions */
Pekka Pessi's avatar
Pekka Pessi committed
414
SOFIAPUBFUN int sdp_media_cmp(sdp_media_t const *, sdp_media_t const *);
Pekka Pessi's avatar
Pekka Pessi committed
415

416
/** Compare two rtpmap structures. */
Pekka Pessi's avatar
Pekka Pessi committed
417
SOFIAPUBFUN int sdp_rtpmap_cmp(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b);
418 419

/** Compare two text lists */
Pekka Pessi's avatar
Pekka Pessi committed
420
SOFIAPUBFUN int sdp_list_cmp(sdp_list_t const *a, sdp_list_t const *b);
421

Pekka Pessi's avatar
Pekka Pessi committed
422
/** Get connections of a media description */
Pekka Pessi's avatar
Pekka Pessi committed
423
SOFIAPUBFUN sdp_connection_t *sdp_media_connections(sdp_media_t const *m);
Pekka Pessi's avatar
Pekka Pessi committed
424 425

/** Check if media uses RTP as its transport protocol  */
Pekka Pessi's avatar
Pekka Pessi committed
426
SOFIAPUBFUN int sdp_media_has_rtp(sdp_media_t const *m);
Pekka Pessi's avatar
Pekka Pessi committed
427 428

/** Set media type */
Pekka Pessi's avatar
Pekka Pessi committed
429
SOFIAPUBFUN void sdp_media_type(sdp_media_t *m, char const *s);
Pekka Pessi's avatar
Pekka Pessi committed
430 431

/** Set transport protocol */
Pekka Pessi's avatar
Pekka Pessi committed
432
SOFIAPUBFUN void sdp_media_transport(sdp_media_t *m, char const *s);
Pekka Pessi's avatar
Pekka Pessi committed
433 434

/** Find named attribute from given list. */
Pekka Pessi's avatar
Pekka Pessi committed
435 436
SOFIAPUBFUN sdp_attribute_t  *sdp_attribute_find(sdp_attribute_t const *a,
						 char const *name);
Pekka Pessi's avatar
Pekka Pessi committed
437 438

/** Find named attribute from given lists. */
Pekka Pessi's avatar
Pekka Pessi committed
439 440 441
SOFIAPUBFUN sdp_attribute_t *sdp_attribute_find2(sdp_attribute_t const *a, 
						 sdp_attribute_t const *a2, 
						 char const *name);
Pekka Pessi's avatar
Pekka Pessi committed
442 443

/** Get session mode from attribute list. */
Pekka Pessi's avatar
Pekka Pessi committed
444 445
SOFIAPUBFUN sdp_mode_t sdp_attribute_mode(sdp_attribute_t const *a,
					  sdp_mode_t defmode);
Pekka Pessi's avatar
Pekka Pessi committed
446 447

/** Get session mode from attribute list. */
Pekka Pessi's avatar
Pekka Pessi committed
448 449
SOFIAPUBFUN sdp_attribute_t *sdp_attribute_by_mode(su_home_t *, 
						   sdp_mode_t mode);
Pekka Pessi's avatar
Pekka Pessi committed
450

451
/** Find a mapped attribute. */
Pekka Pessi's avatar
Pekka Pessi committed
452
SOFIAPUBFUN 
453
sdp_attribute_t *sdp_attribute_mapped_find(sdp_attribute_t const *a, 
Pekka Pessi's avatar
Pekka Pessi committed
454
					   char const *name, 
455
					   int pt, char **return_result);
Pekka Pessi's avatar
Pekka Pessi committed
456

457
/** Append a attribute to a list of attributes. */
Pekka Pessi's avatar
Pekka Pessi committed
458
SOFIAPUBFUN void sdp_attribute_append(sdp_attribute_t **list, 
459 460 461
			  sdp_attribute_t const *a);

/** Replace a attribute within a list of attributes. */
Pekka Pessi's avatar
Pekka Pessi committed
462 463 464
SOFIAPUBFUN int sdp_attribute_replace(sdp_attribute_t **list, 
				      sdp_attribute_t *a,
				      sdp_attribute_t **return_replaced);
465 466

/** Remove a named attribute from a list of attributes. */
Pekka Pessi's avatar
Pekka Pessi committed
467 468
SOFIAPUBFUN sdp_attribute_t *sdp_attribute_remove(sdp_attribute_t **list, 
						  char const *name);
469

470
/* Return 1 if m= line struct matches with given type and name */
Pekka Pessi's avatar
Pekka Pessi committed
471 472 473 474 475
SOFIAPUBFUN unsigned sdp_media_match(sdp_media_t const *m,
				     sdp_media_e type,
				     sdp_text_t *type_name,
				     sdp_proto_e proto,
				     sdp_text_t *proto_name);
476

Pekka Pessi's avatar
Pekka Pessi committed
477 478
SOFIAPUBFUN unsigned sdp_media_match_with(sdp_media_t const *a,
					  sdp_media_t const *b);
479 480

/** Count media lines in SDP. */
Pekka Pessi's avatar
Pekka Pessi committed
481 482 483 484 485
SOFIAPUBFUN unsigned sdp_media_count(sdp_session_t const *sdp,
				     sdp_media_e type,
				     sdp_text_t *type_name,
				     sdp_proto_e proto,
				     sdp_text_t *proto_name);
486

Pekka Pessi's avatar
Pekka Pessi committed
487 488
SOFIAPUBFUN unsigned sdp_media_count_with(sdp_session_t const *sdp,
					  sdp_media_t const *m0);
489

490
/** Return true if media uses RTP */
Pekka Pessi's avatar
Pekka Pessi committed
491
SOFIAPUBFUN int sdp_media_uses_rtp(sdp_media_t const *m);
492 493

/** Check if payload type, rtp rate and parameters match in rtpmaps*/
Pekka Pessi's avatar
Pekka Pessi committed
494
SOFIAPUBFUN int sdp_rtpmap_match(sdp_rtpmap_t const *, sdp_rtpmap_t const *);
495 496

/** Search for matching rtpmap from list */
Pekka Pessi's avatar
Pekka Pessi committed
497 498
SOFIAPUBFUN sdp_rtpmap_t *sdp_rtpmap_find_matching(sdp_rtpmap_t const *list,
						   sdp_rtpmap_t const *rm);
499

Pekka Pessi's avatar
Pekka Pessi committed
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
/* ======================================================================== */

/** Flags given to sdp_parse()/sdp_print(). */
enum sdp_parse_flags_e {
  /** Accept only conforming SDP */
  sdp_f_strict = 1,
  /** Accept any network type. */
  sdp_f_anynet = 2,		
  /** Reallocate message. */ 
  sdp_f_realloc = 4,
  /** Include well-known rtpmaps in message, too */
  sdp_f_all_rtpmaps = 8,
  /** Print buffer already contains a valid prefix */
  sdp_f_print_prefix = 16,
  /** Connection line with INADDR_ANY is considered equal to sendonly */
  sdp_f_mode_0000 = 32,
  /** Don't run sanity check */
  sdp_f_insane = 64,
  /** Don't require c= for each media line */
  sdp_f_c_missing = 128,
  /** Parse SDP config files */
521 522 523
  sdp_f_config = 256,
  /** Do not generate or parse SDP mode */
  sdp_f_mode_manual = 512,
524
  /** Always generate media-level mode attributes */
525
  sdp_f_mode_always = 1024
Pekka Pessi's avatar
Pekka Pessi committed
526 527 528 529 530 531
};

/** SDP parser handle. */
typedef struct sdp_parser_s sdp_parser_t;
typedef sdp_parser_t  *sdp_parser;

Pekka Pessi's avatar
Pekka Pessi committed
532
SOFIAPUBFUN sdp_parser_t *sdp_parse(su_home_t *,
533 534
				    char const msg[], issize_t msgsize,
				    int flags);
Pekka Pessi's avatar
Pekka Pessi committed
535 536 537
SOFIAPUBFUN char const *sdp_parsing_error(sdp_parser_t *p);
SOFIAPUBFUN sdp_session_t *sdp_session(sdp_parser_t *p);
SOFIAPUBFUN void sdp_parser_free(sdp_parser_t *p);
Pekka Pessi's avatar
Pekka Pessi committed
538

Pekka Pessi's avatar
Pekka Pessi committed
539
SOFIAPUBFUN int sdp_sanity_check(sdp_parser_t *);
Pekka Pessi's avatar
Pekka Pessi committed
540

Pekka Pessi's avatar
Pekka Pessi committed
541
SOFIAPUBFUN su_home_t *sdp_parser_home(sdp_parser_t *);
Pekka Pessi's avatar
Pekka Pessi committed
542

Pekka Pessi's avatar
Pekka Pessi committed
543 544 545 546 547 548
/* ======================================================================== */

/** SDP printer handle */
typedef struct sdp_printer_s sdp_printer_t;
typedef sdp_printer_t *sdp_printer;

Pekka Pessi's avatar
Pekka Pessi committed
549
SOFIAPUBFUN sdp_printer_t *sdp_print(su_home_t *, sdp_session_t const *session, 
550
				     char msgbuf[], isize_t maxmsgsize, int flags);
Pekka Pessi's avatar
Pekka Pessi committed
551 552
SOFIAPUBFUN char const *sdp_printing_error(sdp_printer_t *p);
SOFIAPUBFUN char const *sdp_message(sdp_printer_t *p);
553
SOFIAPUBFUN isize_t sdp_message_size(sdp_printer_t *p);
Pekka Pessi's avatar
Pekka Pessi committed
554
SOFIAPUBFUN void sdp_printer_free(sdp_printer_t *p);
Pekka Pessi's avatar
Pekka Pessi committed
555

Pekka Pessi's avatar
Pekka Pessi committed
556
#define sdp_mapped_attribute_find sdp_attribute_mapped_find
Pekka Pessi's avatar
Pekka Pessi committed
557 558 559
#define sdp_free_parser  sdp_parser_free
#define sdp_free_printer sdp_printer_free

560 561
SOFIA_END_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
562
#endif /* SDP_H */