~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.1.0/pjmedia/include/pjmedia/sdp.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: sdp.h 4367 2013-02-21 20:49:19Z nanang $ */
 
2
/* 
 
3
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 
4
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program 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
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 
19
 */
 
20
#ifndef __PJMEDIA_SDP_H__
 
21
#define __PJMEDIA_SDP_H__
 
22
 
 
23
/**
 
24
 * @file sdp.h
 
25
 * @brief SDP header file.
 
26
 */
 
27
#include <pjmedia/types.h>
 
28
#include <pj/sock.h>
 
29
 
 
30
/**
 
31
 * @defgroup PJMEDIA_SDP SDP Parsing and Data Structure
 
32
 * @ingroup PJMEDIA_SESSION
 
33
 * @brief SDP data structure representation and parsing
 
34
 * @{
 
35
 *
 
36
 * The basic SDP session descriptor and elements are described in header
 
37
 * file <b><pjmedia/sdp.h></b>. This file contains declaration for
 
38
 * SDP session descriptor and SDP media descriptor, along with their
 
39
 * attributes. This file also declares functions to parse SDP message.
 
40
 */
 
41
 
 
42
 
 
43
PJ_BEGIN_DECL
 
44
 
 
45
/**
 
46
 * The PJMEDIA_MAX_SDP_FMT macro defines maximum format in a media line.
 
47
 */
 
48
#ifndef PJMEDIA_MAX_SDP_FMT
 
49
#   define PJMEDIA_MAX_SDP_FMT          32
 
50
#endif
 
51
 
 
52
/**
 
53
 * The PJMEDIA_MAX_SDP_BANDW macro defines maximum bandwidth information
 
54
 * lines in a media line.
 
55
 */
 
56
#ifndef PJMEDIA_MAX_SDP_BANDW
 
57
#   define PJMEDIA_MAX_SDP_BANDW        4
 
58
#endif
 
59
 
 
60
/**
 
61
 * The PJMEDIA_MAX_SDP_ATTR macro defines maximum SDP attributes in media and
 
62
 * session descriptor.
 
63
 */
 
64
#ifndef PJMEDIA_MAX_SDP_ATTR
 
65
#   define PJMEDIA_MAX_SDP_ATTR         (PJMEDIA_MAX_SDP_FMT*2 + 4)
 
66
#endif
 
67
 
 
68
/**
 
69
 * The PJMEDIA_MAX_SDP_MEDIA macro defines maximum SDP media lines in a
 
70
 * SDP session descriptor.
 
71
 */
 
72
#ifndef PJMEDIA_MAX_SDP_MEDIA
 
73
#   define PJMEDIA_MAX_SDP_MEDIA        16
 
74
#endif
 
75
 
 
76
 
 
77
/* **************************************************************************
 
78
 * SDP ATTRIBUTES
 
79
 ***************************************************************************
 
80
 */
 
81
 
 
82
/** 
 
83
 * Generic representation of attribute.
 
84
 */
 
85
struct pjmedia_sdp_attr
 
86
{
 
87
    pj_str_t            name;       /**< Attribute name.    */
 
88
    pj_str_t            value;      /**< Attribute value.   */
 
89
};
 
90
 
 
91
/**
 
92
 * @see pjmedia_sdp_attr
 
93
 */
 
94
typedef struct pjmedia_sdp_attr pjmedia_sdp_attr;
 
95
 
 
96
 
 
97
/**
 
98
 * Create SDP attribute.
 
99
 *
 
100
 * @param pool          Pool to create the attribute.
 
101
 * @param name          Attribute name.
 
102
 * @param value         Optional attribute value.
 
103
 *
 
104
 * @return              The new SDP attribute.
 
105
 */
 
106
PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create(pj_pool_t *pool,
 
107
                                                   const char *name,
 
108
                                                   const pj_str_t *value);
 
109
 
 
110
/** 
 
111
 * Clone attribute 
 
112
 *
 
113
 * @param pool          Pool to be used.
 
114
 * @param attr          The attribute to clone.
 
115
 *
 
116
 * @return              New attribute as cloned from the attribute.
 
117
 */
 
118
PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_clone(pj_pool_t *pool, 
 
119
                                                  const pjmedia_sdp_attr*attr);
 
120
 
 
121
/** 
 
122
 * Find the first attribute with the specified type.
 
123
 *
 
124
 * @param count         Number of attributes in the array.
 
125
 * @param attr_array    Array of attributes.
 
126
 * @param name          Attribute name to find.
 
127
 * @param fmt           Optional string to indicate which payload format
 
128
 *                      to find for \a rtpmap and \a fmt attributes. For other
 
129
 *                      types of attributes, the value should be NULL.
 
130
 *
 
131
 * @return              The specified attribute, or NULL if it can't be found.
 
132
 *
 
133
 * @see pjmedia_sdp_attr_find2, pjmedia_sdp_media_find_attr, 
 
134
 *      pjmedia_sdp_media_find_attr2
 
135
 */
 
136
PJ_DECL(pjmedia_sdp_attr*) 
 
137
pjmedia_sdp_attr_find(unsigned count, 
 
138
                      pjmedia_sdp_attr *const attr_array[],
 
139
                      const pj_str_t *name, const pj_str_t *fmt);
 
140
 
 
141
/** 
 
142
 * Find the first attribute with the specified type.
 
143
 *
 
144
 * @param count         Number of attributes in the array.
 
145
 * @param attr_array    Array of attributes.
 
146
 * @param name          Attribute name to find.
 
147
 * @param fmt           Optional string to indicate which payload format
 
148
 *                      to find for \a rtpmap and \a fmt attributes. For other
 
149
 *                      types of attributes, the value should be NULL.
 
150
 *
 
151
 * @return              The specified attribute, or NULL if it can't be found.
 
152
 *
 
153
 * @see pjmedia_sdp_attr_find, pjmedia_sdp_media_find_attr,
 
154
 *      pjmedia_sdp_media_find_attr2
 
155
 */
 
156
PJ_DECL(pjmedia_sdp_attr*) 
 
157
pjmedia_sdp_attr_find2(unsigned count, 
 
158
                       pjmedia_sdp_attr *const attr_array[],
 
159
                       const char *name, const pj_str_t *fmt);
 
160
 
 
161
/**
 
162
 * Add a new attribute to array of attributes.
 
163
 *
 
164
 * @param count         Number of attributes in the array.
 
165
 * @param attr_array    Array of attributes.
 
166
 * @param attr          The attribute to add.
 
167
 *
 
168
 * @return              PJ_SUCCESS or the error code.
 
169
 *
 
170
 * @see pjmedia_sdp_media_add_attr
 
171
 */
 
172
PJ_DECL(pj_status_t) pjmedia_sdp_attr_add(unsigned *count,
 
173
                                          pjmedia_sdp_attr *attr_array[],
 
174
                                          pjmedia_sdp_attr *attr);
 
175
 
 
176
/**
 
177
 * Remove all attributes with the specified name in array of attributes.
 
178
 *
 
179
 * @param count         Number of attributes in the array.
 
180
 * @param attr_array    Array of attributes.
 
181
 * @param name          Attribute name to find.
 
182
 *
 
183
 * @return              Number of attributes removed.
 
184
 *
 
185
 * @see pjmedia_sdp_media_remove_all_attr
 
186
 */
 
187
PJ_DECL(unsigned) pjmedia_sdp_attr_remove_all(unsigned *count,
 
188
                                              pjmedia_sdp_attr *attr_array[],
 
189
                                              const char *name);
 
190
 
 
191
 
 
192
/**
 
193
 * Remove the specified attribute from the attribute array.
 
194
 *
 
195
 * @param count         Number of attributes in the array.
 
196
 * @param attr_array    Array of attributes.
 
197
 * @param attr          The attribute instance to remove.
 
198
 *
 
199
 * @return              PJ_SUCCESS when attribute has been removed, or 
 
200
 *                      PJ_ENOTFOUND when the attribute can not be found.
 
201
 *
 
202
 * @see pjmedia_sdp_media_remove_attr
 
203
 */
 
204
PJ_DECL(pj_status_t) pjmedia_sdp_attr_remove(unsigned *count,
 
205
                                             pjmedia_sdp_attr *attr_array[],
 
206
                                             pjmedia_sdp_attr *attr);
 
207
 
 
208
 
 
209
/**
 
210
 * This structure declares SDP \a rtpmap attribute.
 
211
 */
 
212
struct pjmedia_sdp_rtpmap
 
213
{
 
214
    pj_str_t            pt;         /**< Payload type.      */
 
215
    pj_str_t            enc_name;   /**< Encoding name.     */
 
216
    unsigned            clock_rate; /**< Clock rate.        */
 
217
    pj_str_t            param;      /**< Parameter.         */
 
218
};
 
219
 
 
220
/**
 
221
 * @see pjmedia_sdp_rtpmap
 
222
 */
 
223
typedef struct pjmedia_sdp_rtpmap pjmedia_sdp_rtpmap;
 
224
 
 
225
 
 
226
/**
 
227
 * Convert generic attribute to SDP \a rtpmap. This function allocates
 
228
 * a new attribute and call #pjmedia_sdp_attr_get_rtpmap().
 
229
 *
 
230
 * @param pool          Pool used to create the rtpmap attribute.
 
231
 * @param attr          Generic attribute to be converted to rtpmap, which
 
232
 *                      name must be "rtpmap".
 
233
 * @param p_rtpmap      Pointer to receive SDP rtpmap attribute.
 
234
 *
 
235
 * @return              PJ_SUCCESS if the attribute can be successfully
 
236
 *                      converted to \a rtpmap type.
 
237
 *
 
238
 * @see pjmedia_sdp_attr_get_rtpmap
 
239
 */
 
240
PJ_DECL(pj_status_t) pjmedia_sdp_attr_to_rtpmap(pj_pool_t *pool,
 
241
                                                const pjmedia_sdp_attr *attr,
 
242
                                                pjmedia_sdp_rtpmap **p_rtpmap);
 
243
 
 
244
 
 
245
/**
 
246
 * Get the rtpmap representation of the same SDP attribute.
 
247
 *
 
248
 * @param attr          Generic attribute to be converted to rtpmap, which
 
249
 *                      name must be "rtpmap".
 
250
 * @param rtpmap        SDP \a rtpmap attribute to be initialized.
 
251
 *
 
252
 * @return              PJ_SUCCESS if the attribute can be successfully
 
253
 *                      converted to \a rtpmap attribute.
 
254
 *
 
255
 * @see pjmedia_sdp_attr_to_rtpmap
 
256
 */
 
257
PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtpmap(const pjmedia_sdp_attr *attr,
 
258
                                                 pjmedia_sdp_rtpmap *rtpmap);
 
259
 
 
260
 
 
261
/**
 
262
 * Convert \a rtpmap attribute to generic attribute.
 
263
 *
 
264
 * @param pool          Pool to be used.
 
265
 * @param rtpmap        The \a rtpmap attribute.
 
266
 * @param p_attr        Pointer to receive the generic SDP attribute.
 
267
 *
 
268
 * @return              PJ_SUCCESS on success.
 
269
 */
 
270
PJ_DECL(pj_status_t) 
 
271
pjmedia_sdp_rtpmap_to_attr( pj_pool_t *pool,
 
272
                            const pjmedia_sdp_rtpmap *rtpmap,
 
273
                            pjmedia_sdp_attr **p_attr);
 
274
 
 
275
 
 
276
/**
 
277
 * This structure describes SDP \a fmtp attribute.
 
278
 */
 
279
typedef struct pjmedia_sdp_fmtp
 
280
{
 
281
    pj_str_t            fmt;        /**< Format type.               */
 
282
    pj_str_t            fmt_param;  /**< Format specific parameter. */
 
283
} pjmedia_sdp_fmtp;
 
284
 
 
285
 
 
286
/**
 
287
 * Get the fmtp representation of the same SDP attribute.
 
288
 *
 
289
 * @param attr          Generic attribute to be converted to fmtp, which
 
290
 *                      name must be "fmtp".
 
291
 * @param fmtp          SDP fmtp attribute to be initialized.
 
292
 *
 
293
 * @return              PJ_SUCCESS on success.
 
294
 */
 
295
PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_fmtp(const pjmedia_sdp_attr *attr,
 
296
                                               pjmedia_sdp_fmtp *fmtp);
 
297
 
 
298
 
 
299
/**
 
300
 * This structure describes SDP \a rtcp attribute.
 
301
 */
 
302
typedef struct pjmedia_sdp_rtcp_attr
 
303
{
 
304
    unsigned    port;       /**< RTCP port number.          */
 
305
    pj_str_t    net_type;   /**< Optional network type.     */
 
306
    pj_str_t    addr_type;  /**< Optional address type.     */
 
307
    pj_str_t    addr;       /**< Optional address.          */
 
308
} pjmedia_sdp_rtcp_attr;
 
309
 
 
310
 
 
311
/**
 
312
 * Parse a generic SDP attribute to get SDP rtcp attribute values.
 
313
 *
 
314
 * @param attr          Generic attribute to be converted to rtcp, which
 
315
 *                      name must be "rtcp".
 
316
 * @param rtcp          SDP rtcp attribute to be initialized.
 
317
 *
 
318
 * @return              PJ_SUCCESS on success.
 
319
 */
 
320
PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr,
 
321
                                               pjmedia_sdp_rtcp_attr *rtcp);
 
322
 
 
323
 
 
324
/**
 
325
 * Create a=rtcp attribute.
 
326
 *
 
327
 * @param pool          Pool to create the attribute.
 
328
 * @param a             Socket address.
 
329
 *
 
330
 * @return              SDP RTCP attribute.
 
331
 */
 
332
PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_rtcp(pj_pool_t *pool,
 
333
                                                        const pj_sockaddr *a);
 
334
 
 
335
 
 
336
/* **************************************************************************
 
337
 * SDP CONNECTION INFO
 
338
 ****************************************************************************
 
339
 */
 
340
 
 
341
/**
 
342
 * This structure describes SDP connection info ("c=" line). 
 
343
 */
 
344
struct pjmedia_sdp_conn
 
345
{
 
346
    pj_str_t    net_type;       /**< Network type ("IN").               */
 
347
    pj_str_t    addr_type;      /**< Address type ("IP4", "IP6").       */
 
348
    pj_str_t    addr;           /**< The address.                       */
 
349
};
 
350
 
 
351
 
 
352
/**
 
353
 * @see pjmedia_sdp_conn
 
354
 */
 
355
typedef struct pjmedia_sdp_conn pjmedia_sdp_conn;
 
356
 
 
357
 
 
358
/** 
 
359
 * Clone connection info. 
 
360
 * 
 
361
 * @param pool      Pool to allocate memory for the new connection info.
 
362
 * @param rhs       The connection into to clone.
 
363
 *
 
364
 * @return          The new connection info.
 
365
 */
 
366
PJ_DECL(pjmedia_sdp_conn*) pjmedia_sdp_conn_clone(pj_pool_t *pool, 
 
367
                                                  const pjmedia_sdp_conn *rhs);
 
368
 
 
369
 
 
370
/** 
 
371
 * Compare connection info. 
 
372
 * 
 
373
 * @param conn1     The first connection info to compare.
 
374
 * @param conn1     The second connection info to compare.
 
375
 * @param option    Comparison option, which should be zero for now.
 
376
 *
 
377
 * @return          PJ_SUCCESS when both connection info are equal, otherwise
 
378
 *                  returns PJMEDIA_SDP_ECONNNOTEQUAL.
 
379
 */
 
380
PJ_DECL(pj_status_t) pjmedia_sdp_conn_cmp(const pjmedia_sdp_conn *conn1, 
 
381
                                          const pjmedia_sdp_conn *conn2,
 
382
                                          unsigned option);
 
383
 
 
384
 
 
385
/* **************************************************************************
 
386
 * SDP BANDWIDTH INFO
 
387
 ****************************************************************************
 
388
 */
 
389
 
 
390
/**
 
391
 * This structure describes SDP bandwidth info ("b=" line). 
 
392
 */
 
393
typedef struct pjmedia_sdp_bandw
 
394
{
 
395
    pj_str_t    modifier;       /**< Bandwidth modifier.                */
 
396
    pj_uint32_t value;          /**< Bandwidth value.                   */
 
397
} pjmedia_sdp_bandw;
 
398
 
 
399
 
 
400
/** 
 
401
 * Clone bandwidth info. 
 
402
 * 
 
403
 * @param pool      Pool to allocate memory for the new bandwidth info.
 
404
 * @param rhs       The bandwidth into to clone.
 
405
 *
 
406
 * @return          The new bandwidth info.
 
407
 */
 
408
PJ_DECL(pjmedia_sdp_bandw*)
 
409
pjmedia_sdp_bandw_clone(pj_pool_t *pool, const pjmedia_sdp_bandw *rhs);
 
410
 
 
411
 
 
412
 
 
413
/* **************************************************************************
 
414
 * SDP MEDIA INFO/LINE
 
415
 ****************************************************************************
 
416
 */
 
417
 
 
418
/**
 
419
 * This structure describes SDP media descriptor. A SDP media descriptor
 
420
 * starts with "m=" line and contains the media attributes and optional
 
421
 * connection line.
 
422
 */
 
423
struct pjmedia_sdp_media
 
424
{
 
425
    /** Media descriptor line ("m=" line) */
 
426
    struct
 
427
    {
 
428
        pj_str_t    media;              /**< Media type ("audio", "video")  */
 
429
        pj_uint16_t port;               /**< Port number.                   */
 
430
        unsigned    port_count;         /**< Port count, used only when >2  */
 
431
        pj_str_t    transport;          /**< Transport ("RTP/AVP")          */
 
432
        unsigned    fmt_count;          /**< Number of formats.             */
 
433
        pj_str_t    fmt[PJMEDIA_MAX_SDP_FMT];       /**< Media formats.     */
 
434
    } desc;
 
435
 
 
436
    pjmedia_sdp_conn   *conn;           /**< Optional connection info.      */
 
437
    unsigned            bandw_count;    /**< Number of bandwidth info.      */
 
438
    pjmedia_sdp_bandw  *bandw[PJMEDIA_MAX_SDP_BANDW]; /**< Bandwidth info.  */
 
439
    unsigned            attr_count;     /**< Number of attributes.          */
 
440
    pjmedia_sdp_attr   *attr[PJMEDIA_MAX_SDP_ATTR];   /**< Attributes.      */
 
441
 
 
442
};
 
443
 
 
444
 
 
445
/**
 
446
 * @see pjmedia_sdp_media
 
447
 */
 
448
typedef struct pjmedia_sdp_media pjmedia_sdp_media;
 
449
 
 
450
 
 
451
/** 
 
452
 * Clone SDP media description. 
 
453
 *
 
454
 * @param pool      Pool to allocate memory for the new media description.
 
455
 * @param rhs       The media descriptin to clone.
 
456
 *
 
457
 * @return          New media description.
 
458
 */
 
459
PJ_DECL(pjmedia_sdp_media*) 
 
460
pjmedia_sdp_media_clone( pj_pool_t *pool, 
 
461
                         const pjmedia_sdp_media *rhs);
 
462
 
 
463
/**
 
464
 * Find the first occurence of the specified attribute name in the media 
 
465
 * descriptor. Optionally the format may be specified.
 
466
 *
 
467
 * @param m             The SDP media description.
 
468
 * @param name          Attribute name to find.
 
469
 * @param fmt           Optional payload type to match in the
 
470
 *                      attribute list, when the attribute is \a rtpmap
 
471
 *                      or \a fmtp. For other types of SDP attributes, this
 
472
 *                      value should be NULL.
 
473
 *
 
474
 * @return              The first instance of the specified attribute or NULL.
 
475
 */
 
476
PJ_DECL(pjmedia_sdp_attr*) 
 
477
pjmedia_sdp_media_find_attr(const pjmedia_sdp_media *m,
 
478
                            const pj_str_t *name, const pj_str_t *fmt);
 
479
 
 
480
 
 
481
/**
 
482
 * Find the first occurence of the specified attribute name in the SDP media 
 
483
 * descriptor. Optionally the format may be specified.
 
484
 *
 
485
 * @param m             The SDP media description.
 
486
 * @param name          Attribute name to find.
 
487
 * @param fmt           Optional payload type to match in the
 
488
 *                      attribute list, when the attribute is \a rtpmap
 
489
 *                      or \a fmtp. For other types of SDP attributes, this
 
490
 *                      value should be NULL.
 
491
 *
 
492
 * @return              The first instance of the specified attribute or NULL.
 
493
 */
 
494
PJ_DECL(pjmedia_sdp_attr*) 
 
495
pjmedia_sdp_media_find_attr2(const pjmedia_sdp_media *m,
 
496
                             const char *name, const pj_str_t *fmt);
 
497
 
 
498
/**
 
499
 * Add new attribute to the media descriptor.
 
500
 *
 
501
 * @param m             The SDP media description.
 
502
 * @param attr          Attribute to add.
 
503
 *
 
504
 * @return              PJ_SUCCESS or the appropriate error code.
 
505
 */
 
506
PJ_DECL(pj_status_t) pjmedia_sdp_media_add_attr(pjmedia_sdp_media *m,
 
507
                                                pjmedia_sdp_attr *attr);
 
508
 
 
509
/**
 
510
 * Remove all attributes with the specified name from the SDP media
 
511
 * descriptor.
 
512
 *
 
513
 * @param m             The SDP media description.
 
514
 * @param name          Attribute name to remove.
 
515
 *
 
516
 * @return              The number of attributes removed.
 
517
 */
 
518
PJ_DECL(unsigned) 
 
519
pjmedia_sdp_media_remove_all_attr(pjmedia_sdp_media *m,
 
520
                                  const char *name);
 
521
 
 
522
 
 
523
/**
 
524
 * Remove the occurence of the specified attribute from the SDP media
 
525
 * descriptor.
 
526
 *
 
527
 * @param m             The SDP media descriptor.
 
528
 * @param attr          The attribute to find and remove.
 
529
 *
 
530
 * @return              PJ_SUCCESS if the attribute can be found and has
 
531
 *                      been removed from the array.
 
532
 */
 
533
PJ_DECL(pj_status_t)
 
534
pjmedia_sdp_media_remove_attr(pjmedia_sdp_media *m,
 
535
                              pjmedia_sdp_attr *attr);
 
536
 
 
537
 
 
538
/**
 
539
 * Compare two SDP media for equality.
 
540
 *
 
541
 * @param sd1       The first SDP media to compare.
 
542
 * @param sd2       The second SDP media to compare.
 
543
 * @param option    Comparison option, which should be zero for now.
 
544
 *
 
545
 * @return          PJ_SUCCESS when both SDP medias are equal, or the
 
546
 *                  appropriate status code describing which part of
 
547
 *                  the descriptors that are not equal.
 
548
 */
 
549
PJ_DECL(pj_status_t) pjmedia_sdp_media_cmp(const pjmedia_sdp_media *sd1,
 
550
                                           const pjmedia_sdp_media *sd2,
 
551
                                           unsigned option);
 
552
 
 
553
 
 
554
/**
 
555
 * Compare two media transports for compatibility.
 
556
 *
 
557
 * @param t1        The first media transport to compare.
 
558
 * @param t2        The second media transport to compare.
 
559
 *
 
560
 * @return          PJ_SUCCESS when both media transports are compatible,
 
561
 *                  otherwise returns PJMEDIA_SDP_ETPORTNOTEQUAL.
 
562
 */
 
563
PJ_DECL(pj_status_t) pjmedia_sdp_transport_cmp(const pj_str_t *t1,
 
564
                                               const pj_str_t *t2);
 
565
 
 
566
 
 
567
/**
 
568
 * Deactivate SDP media.
 
569
 *
 
570
 * @param pool      Memory pool to allocate memory from.
 
571
 * @param m         The SDP media to deactivate.
 
572
 *
 
573
 * @return          PJ_SUCCESS when SDP media successfully deactivated,
 
574
 *                  otherwise appropriate status code returned.
 
575
 */
 
576
PJ_DECL(pj_status_t) pjmedia_sdp_media_deactivate(pj_pool_t *pool,
 
577
                                                  pjmedia_sdp_media *m);
 
578
 
 
579
 
 
580
/**
 
581
 * Clone SDP media description and deactivate the new SDP media.
 
582
 *
 
583
 * @param pool      Memory pool to allocate memory for the clone.
 
584
 * @param rhs       The SDP media to clone.
 
585
 *
 
586
 * @return          New media descrption with deactivated indication.
 
587
 */
 
588
PJ_DECL(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate(
 
589
                                                pj_pool_t *pool,
 
590
                                                const pjmedia_sdp_media *rhs);
 
591
 
 
592
 
 
593
/* **************************************************************************
 
594
 * SDP SESSION DESCRIPTION
 
595
 ****************************************************************************
 
596
 */
 
597
 
 
598
 
 
599
/**
 
600
 * This structure describes SDP session description. A SDP session descriptor
 
601
 * contains complete information about a session, and normally is exchanged
 
602
 * with remote media peer using signaling protocol such as SIP.
 
603
 */
 
604
struct pjmedia_sdp_session
 
605
{
 
606
    /** Session origin (o= line) */
 
607
    struct
 
608
    {
 
609
        pj_str_t    user;           /**< User                           */
 
610
        pj_uint32_t id;             /**< Session ID                     */
 
611
        pj_uint32_t version;        /**< Session version                */
 
612
        pj_str_t    net_type;       /**< Network type ("IN")            */
 
613
        pj_str_t    addr_type;      /**< Address type ("IP4", "IP6")    */
 
614
        pj_str_t    addr;           /**< The address.                   */
 
615
    } origin;
 
616
 
 
617
    pj_str_t           name;        /**< Subject line (s=)              */
 
618
    pjmedia_sdp_conn  *conn;        /**< Connection line (c=)           */
 
619
    unsigned           bandw_count; /**< Number of bandwidth info (b=)  */
 
620
    pjmedia_sdp_bandw *bandw[PJMEDIA_MAX_SDP_BANDW];
 
621
                                    /**< Bandwidth info array (b=)      */
 
622
    
 
623
    /** Session time (t= line)  */
 
624
    struct
 
625
    {
 
626
        pj_uint32_t start;          /**< Start time.                    */
 
627
        pj_uint32_t stop;           /**< Stop time.                     */
 
628
    } time;
 
629
 
 
630
    unsigned           attr_count;              /**< Number of attributes.  */
 
631
    pjmedia_sdp_attr  *attr[PJMEDIA_MAX_SDP_ATTR]; /**< Attributes array.   */
 
632
 
 
633
    unsigned           media_count;             /**< Number of media.       */
 
634
    pjmedia_sdp_media *media[PJMEDIA_MAX_SDP_MEDIA];    /**< Media array.   */
 
635
 
 
636
};
 
637
 
 
638
/**
 
639
 * @see pjmedia_sdp_session
 
640
 */
 
641
typedef struct pjmedia_sdp_session pjmedia_sdp_session;
 
642
 
 
643
 
 
644
 
 
645
/**
 
646
 * Parse SDP message.
 
647
 *
 
648
 * @param pool      The pool to allocate SDP session description.
 
649
 * @param buf       The message buffer.
 
650
 * @param len       The length of the message.
 
651
 * @param p_sdp     Pointer to receive the SDP session descriptor.
 
652
 *
 
653
 * @return          PJ_SUCCESS if message was successfully parsed into
 
654
 *                  SDP session descriptor.
 
655
 */
 
656
PJ_DECL(pj_status_t) pjmedia_sdp_parse( pj_pool_t *pool,
 
657
                                        char *buf, pj_size_t len, 
 
658
                                        pjmedia_sdp_session **p_sdp );
 
659
 
 
660
/**
 
661
 * Print SDP description to a buffer.
 
662
 *
 
663
 * @param sdp       The SDP session description.
 
664
 * @param buf       The buffer.
 
665
 * @param size      The buffer length.
 
666
 *
 
667
 * @return          the length printed, or -1 if the buffer is too
 
668
 *                  short.
 
669
 */
 
670
PJ_DECL(int) pjmedia_sdp_print( const pjmedia_sdp_session *sdp, 
 
671
                                char *buf, pj_size_t size);
 
672
 
 
673
 
 
674
/**
 
675
 * Perform semantic validation for the specified SDP session descriptor.
 
676
 * This function perform validation beyond just syntactic verification,
 
677
 * such as to verify the value of network type and address type, check
 
678
 * the connection line, and verify that \a rtpmap attribute is present
 
679
 * when dynamic payload type is used.
 
680
 *
 
681
 * @param sdp       The SDP session descriptor to validate.
 
682
 *
 
683
 * @return          PJ_SUCCESS on success.
 
684
 */
 
685
PJ_DECL(pj_status_t) pjmedia_sdp_validate(const pjmedia_sdp_session *sdp);
 
686
 
 
687
 
 
688
/**
 
689
 * Perform semantic validation for the specified SDP session descriptor.
 
690
 * This function perform validation beyond just syntactic verification,
 
691
 * such as to verify the value of network type and address type, check
 
692
 * the connection line, and verify that \a rtpmap attribute is present
 
693
 * when dynamic payload type is used.
 
694
 *
 
695
 * @param sdp       The SDP session descriptor to validate.
 
696
 * @param strict    Flag whether the check should be strict, i.e: allow
 
697
 *                  media without connection line when port is zero.
 
698
 *
 
699
 * @return          PJ_SUCCESS on success.
 
700
 */
 
701
PJ_DECL(pj_status_t) pjmedia_sdp_validate2(const pjmedia_sdp_session *sdp,
 
702
                                           pj_bool_t strict);
 
703
 
 
704
 
 
705
/**
 
706
 * Clone SDP session descriptor.
 
707
 *
 
708
 * @param pool      The pool used to clone the session.
 
709
 * @param sdp       The SDP session to clone.
 
710
 *
 
711
 * @return          New SDP session.
 
712
 */
 
713
PJ_DECL(pjmedia_sdp_session*) 
 
714
pjmedia_sdp_session_clone( pj_pool_t *pool,
 
715
                           const pjmedia_sdp_session *sdp);
 
716
 
 
717
 
 
718
/**
 
719
 * Compare two SDP session for equality.
 
720
 *
 
721
 * @param sd1       The first SDP session to compare.
 
722
 * @param sd2       The second SDP session to compare.
 
723
 * @param option    Must be zero for now.
 
724
 *
 
725
 * @return          PJ_SUCCESS when both SDPs are equal, or otherwise
 
726
 *                  the status code indicates which part of the session
 
727
 *                  descriptors are not equal.
 
728
 */
 
729
PJ_DECL(pj_status_t) pjmedia_sdp_session_cmp(const pjmedia_sdp_session *sd1,
 
730
                                             const pjmedia_sdp_session *sd2,
 
731
                                             unsigned option);
 
732
 
 
733
 
 
734
/**
 
735
 * Add new attribute to the session descriptor.
 
736
 *
 
737
 * @param s             The SDP session description.
 
738
 * @param attr          Attribute to add.
 
739
 *
 
740
 * @return              PJ_SUCCESS or the appropriate error code.
 
741
 */
 
742
PJ_DECL(pj_status_t) pjmedia_sdp_session_add_attr(pjmedia_sdp_session *s,
 
743
                                                  pjmedia_sdp_attr *attr);
 
744
 
 
745
 
 
746
PJ_END_DECL
 
747
 
 
748
/**
 
749
 * @}
 
750
 */
 
751
 
 
752
#endif  /* __PJMEDIA_SDP_H__ */
 
753