00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SDP_H
00026 #define SDP_H
00027
00035 #ifndef SU_ALLOC_H
00036 #include <sofia-sip/su_alloc.h>
00037 #endif
00038 #ifndef SU_TYPES_H
00039 #include <sofia-sip/su_types.h>
00040 #endif
00041
00042 SOFIA_BEGIN_DECLS
00043
00045 typedef struct sdp_session_s sdp_session_t;
00047 typedef unsigned long sdp_version_t;
00049 typedef struct sdp_origin_s sdp_origin_t;
00051 typedef struct sdp_connection_s sdp_connection_t;
00053 typedef struct sdp_bandwidth_s sdp_bandwidth_t;
00055 typedef struct sdp_time_s sdp_time_t;
00057 typedef struct sdp_repeat_s sdp_repeat_t;
00059 typedef struct sdp_zone_s sdp_zone_t;
00061 typedef struct sdp_key_s sdp_key_t;
00063 typedef struct sdp_attribute_s sdp_attribute_t;
00065 typedef struct sdp_media_s sdp_media_t;
00067 typedef struct sdp_list_s sdp_list_t;
00069 typedef struct sdp_rtpmap_s sdp_rtpmap_t;
00070
00072 typedef char const sdp_text_t;
00073
00074 #define SDP_MIME_TYPE "application/sdp"
00075
00076 enum {
00077 SDP_CURRENT_VERSION = 0
00078 };
00079
00081 struct sdp_session_s
00082 {
00083 int sdp_size;
00084 sdp_session_t *sdp_next;
00085 sdp_version_t sdp_version[1];
00086 sdp_origin_t *sdp_origin;
00087 sdp_text_t *sdp_subject;
00088 sdp_text_t *sdp_information;
00089 sdp_text_t *sdp_uri;
00090 sdp_list_t *sdp_emails;
00091 sdp_list_t *sdp_phones;
00092 sdp_connection_t *sdp_connection;
00093 sdp_bandwidth_t *sdp_bandwidths;
00094 sdp_time_t *sdp_time;
00095 sdp_key_t *sdp_key;
00096 sdp_attribute_t *sdp_attributes;
00097 sdp_text_t *sdp_charset;
00098 sdp_media_t *sdp_media;
00099 };
00100
00102 struct sdp_origin_s
00103 {
00104 int o_size;
00105 sdp_text_t *o_username;
00106 uint64_t o_id;
00107 uint64_t o_version;
00108 sdp_connection_t *o_address;
00109 };
00110
00112 typedef enum
00113 {
00114 sdp_net_x = 0,
00115 sdp_net_in = 1
00116 } sdp_nettype_e;
00117
00119 typedef enum
00120 {
00121 sdp_addr_x = 0,
00122 sdp_addr_ip4 = 1,
00123 sdp_addr_ip6 = 2,
00124 } sdp_addrtype_e;
00125
00127 struct sdp_connection_s
00128 {
00129 int c_size;
00130 sdp_connection_t *c_next;
00131 sdp_nettype_e c_nettype;
00132 sdp_addrtype_e c_addrtype;
00133 sdp_text_t *c_address;
00134 unsigned c_ttl : 8;
00135 unsigned c_mcast : 1;
00136 unsigned : 0;
00137 unsigned c_groups;
00138 };
00139
00141 typedef enum
00142 {
00143 sdp_bw_x,
00144 sdp_bw_ct,
00145 sdp_bw_as,
00146 } sdp_bandwidth_e;
00147
00149 struct sdp_bandwidth_s
00150 {
00151 int b_size;
00152 sdp_bandwidth_t *b_next;
00153 sdp_bandwidth_e b_modifier;
00155 sdp_text_t *b_modifier_name;
00156 unsigned long b_value;
00157 };
00158
00160 struct sdp_time_s
00161 {
00162 int t_size;
00163 sdp_time_t *t_next;
00164 unsigned long t_start;
00165 unsigned long t_stop;
00166 sdp_repeat_t *t_repeat;
00167 sdp_zone_t *t_zone;
00168 };
00169
00171 struct sdp_repeat_s
00172 {
00173 int r_size;
00176 int r_number_of_offsets;
00177 unsigned long r_interval;
00178 unsigned long r_duration;
00179 unsigned long r_offsets[1];
00180 };
00181
00183 struct sdp_zone_s
00184 {
00186 int z_size;
00187 int z_number_of_adjustments;
00188 struct {
00189 unsigned long z_at;
00190 long z_offset;
00191 } z_adjustments[1];
00192 };
00193
00195 typedef enum {
00196 sdp_key_x,
00197 sdp_key_clear,
00198 sdp_key_base64,
00199 sdp_key_uri,
00200 sdp_key_prompt
00202 } sdp_key_method_e;
00203
00205 struct sdp_key_s
00206 {
00207 int k_size;
00208 sdp_key_method_e k_method;
00209 sdp_text_t *k_method_name;
00210 sdp_text_t *k_material;
00211 };
00212
00214 struct sdp_attribute_s {
00215 int a_size;
00216 sdp_attribute_t *a_next;
00217 sdp_text_t *a_name;
00218 sdp_text_t *a_value;
00219 };
00220
00222 typedef enum
00223 {
00224 sdp_media_x = 0,
00225 sdp_media_any,
00226 sdp_media_audio,
00227 sdp_media_video,
00228 sdp_media_application,
00229 sdp_media_data,
00230 sdp_media_control,
00231 sdp_media_message,
00232 sdp_media_image,
00234 sdp_media_red
00235 } sdp_media_e;
00236
00238 typedef enum
00239 {
00240 sdp_proto_x = 0,
00241 sdp_proto_tcp = 6,
00242 sdp_proto_udp = 17,
00243 sdp_proto_rtp = 256,
00244 sdp_proto_srtp = 257,
00245 sdp_proto_udptl = 258,
00246 sdp_proto_tls = 511,
00247 sdp_proto_any = 512
00248 } sdp_proto_e;
00249
00251 typedef enum {
00252 sdp_inactive = 0,
00253 sdp_sendonly = 1,
00254 sdp_recvonly = 2,
00255 sdp_sendrecv = sdp_sendonly | sdp_recvonly
00256 } sdp_mode_t;
00257
00268 struct sdp_media_s
00269 {
00270 int m_size;
00271 sdp_media_t *m_next;
00272 sdp_session_t *m_session;
00274 sdp_media_e m_type;
00275 sdp_text_t *m_type_name;
00276 unsigned long m_port;
00277 unsigned long m_number_of_ports;
00278 sdp_proto_e m_proto;
00279 sdp_text_t *m_proto_name;
00280 sdp_list_t *m_format;
00281 sdp_rtpmap_t *m_rtpmaps;
00282 sdp_text_t *m_information;
00283 sdp_connection_t *m_connections;
00284 sdp_bandwidth_t *m_bandwidths;
00285 sdp_key_t *m_key;
00286 sdp_attribute_t *m_attributes;
00288 void *m_user;
00291 unsigned m_rejected : 1;
00293 unsigned m_mode : 2;
00294 unsigned : 0;
00295 };
00296
00298 struct sdp_list_s
00299 {
00300 int l_size;
00301 sdp_list_t *l_next;
00302 sdp_text_t *l_text;
00303 };
00304
00314 struct sdp_rtpmap_s {
00315 int rm_size;
00316 sdp_rtpmap_t *rm_next;
00317 sdp_text_t *rm_encoding;
00318 unsigned long rm_rate;
00319 sdp_text_t *rm_params;
00320 sdp_text_t *rm_fmtp;
00321 unsigned rm_predef : 1;
00322 unsigned rm_pt : 7;
00323 unsigned rm_any : 1;
00324 unsigned :0;
00325 };
00326
00327 SOFIAPUBVAR sdp_rtpmap_t const * const sdp_rtpmap_well_known[128];
00328
00330 SOFIAPUBFUN sdp_session_t *sdp_session_dup(su_home_t *, sdp_session_t const *);
00331
00333 SOFIAPUBFUN
00334 sdp_origin_t *sdp_origin_dup(su_home_t *, sdp_origin_t const *);
00335
00337 SOFIAPUBFUN
00338 sdp_connection_t *sdp_connection_dup(su_home_t *, sdp_connection_t const *);
00339
00341 SOFIAPUBFUN
00342 sdp_bandwidth_t *sdp_bandwidth_dup(su_home_t *, sdp_bandwidth_t const *);
00343
00345 SOFIAPUBFUN
00346 sdp_time_t *sdp_time_dup(su_home_t *, sdp_time_t const *);
00347
00349 SOFIAPUBFUN
00350 sdp_repeat_t *sdp_repeat_dup(su_home_t *, sdp_repeat_t const *);
00351
00353 SOFIAPUBFUN
00354 sdp_zone_t *sdp_zone_dup(su_home_t *, sdp_zone_t const *);
00355
00357 SOFIAPUBFUN
00358 sdp_key_t *sdp_key_dup(su_home_t *, sdp_key_t const *);
00359
00361 SOFIAPUBFUN
00362 sdp_attribute_t *sdp_attribute_dup(su_home_t *, sdp_attribute_t const *);
00363
00365 SOFIAPUBFUN
00366 sdp_media_t *sdp_media_dup(su_home_t *, sdp_media_t const *,
00367 sdp_session_t *);
00368
00370 SOFIAPUBFUN
00371 sdp_media_t *sdp_media_dup_all(su_home_t *, sdp_media_t const *,
00372 sdp_session_t *);
00373
00375 SOFIAPUBFUN
00376 sdp_list_t *sdp_list_dup(su_home_t *, sdp_list_t const *);
00377
00379 SOFIAPUBFUN
00380 sdp_rtpmap_t *sdp_rtpmap_dup(su_home_t *, sdp_rtpmap_t const *);
00381
00383 SOFIAPUBFUN int sdp_session_cmp(sdp_session_t const *a,
00384 sdp_session_t const *b);
00385
00387 SOFIAPUBFUN int sdp_origin_cmp(sdp_origin_t const *a,
00388 sdp_origin_t const *b);
00389
00391 SOFIAPUBFUN int sdp_connection_cmp(sdp_connection_t const *,
00392 sdp_connection_t const *b);
00393
00395 SOFIAPUBFUN int sdp_bandwidth_cmp(sdp_bandwidth_t const *a,
00396 sdp_bandwidth_t const *b);
00397
00399 SOFIAPUBFUN int sdp_time_cmp(sdp_time_t const *a, sdp_time_t const *b);
00400
00401
00402 SOFIAPUBFUN int sdp_repeat_cmp(sdp_repeat_t const *a, sdp_repeat_t const *b);
00403
00404
00405 SOFIAPUBFUN int sdp_zone_cmp(sdp_zone_t const *a, sdp_zone_t const *b);
00406
00408 SOFIAPUBFUN int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b);
00409
00411 SOFIAPUBFUN int sdp_attribute_cmp(sdp_attribute_t const *,
00412 sdp_attribute_t const *);
00413
00415 SOFIAPUBFUN int sdp_media_cmp(sdp_media_t const *, sdp_media_t const *);
00416
00418 SOFIAPUBFUN int sdp_rtpmap_cmp(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b);
00419
00421 SOFIAPUBFUN int sdp_list_cmp(sdp_list_t const *a, sdp_list_t const *b);
00422
00424 SOFIAPUBFUN sdp_connection_t *sdp_media_connections(sdp_media_t const *m);
00425
00427 SOFIAPUBFUN int sdp_media_has_rtp(sdp_media_t const *m);
00428
00430 SOFIAPUBFUN void sdp_media_type(sdp_media_t *m, char const *s);
00431
00433 SOFIAPUBFUN void sdp_media_transport(sdp_media_t *m, char const *s);
00434
00436 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_find(sdp_attribute_t const *a,
00437 char const *name);
00438
00440 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_find2(sdp_attribute_t const *a,
00441 sdp_attribute_t const *a2,
00442 char const *name);
00443
00445 SOFIAPUBFUN sdp_mode_t sdp_attribute_mode(sdp_attribute_t const *a,
00446 sdp_mode_t defmode);
00447
00449 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_by_mode(su_home_t *,
00450 sdp_mode_t mode);
00451
00453 SOFIAPUBFUN
00454 sdp_attribute_t *sdp_attribute_mapped_find(sdp_attribute_t const *a,
00455 char const *name,
00456 int pt, char **return_result);
00457
00459 SOFIAPUBFUN void sdp_attribute_append(sdp_attribute_t **list,
00460 sdp_attribute_t const *a);
00461
00463 SOFIAPUBFUN int sdp_attribute_replace(sdp_attribute_t **list,
00464 sdp_attribute_t *a,
00465 sdp_attribute_t **return_replaced);
00466
00468 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_remove(sdp_attribute_t **list,
00469 char const *name);
00470
00471
00472 SOFIAPUBFUN unsigned sdp_media_match(sdp_media_t const *m,
00473 sdp_media_e type,
00474 sdp_text_t *type_name,
00475 sdp_proto_e proto,
00476 sdp_text_t *proto_name);
00477
00478 SOFIAPUBFUN unsigned sdp_media_match_with(sdp_media_t const *a,
00479 sdp_media_t const *b);
00480
00482 SOFIAPUBFUN unsigned sdp_media_count(sdp_session_t const *sdp,
00483 sdp_media_e type,
00484 sdp_text_t *type_name,
00485 sdp_proto_e proto,
00486 sdp_text_t *proto_name);
00487
00488 SOFIAPUBFUN unsigned sdp_media_count_with(sdp_session_t const *sdp,
00489 sdp_media_t const *m0);
00490
00492 SOFIAPUBFUN int sdp_media_uses_rtp(sdp_media_t const *m);
00493
00495 SOFIAPUBFUN int sdp_rtpmap_match(sdp_rtpmap_t const *, sdp_rtpmap_t const *);
00496
00498 SOFIAPUBFUN sdp_rtpmap_t *sdp_rtpmap_find_matching(sdp_rtpmap_t const *list,
00499 sdp_rtpmap_t const *rm);
00500
00501
00502
00504 enum sdp_parse_flags_e {
00506 sdp_f_strict = 1,
00508 sdp_f_anynet = 2,
00510 sdp_f_realloc = 4,
00512 sdp_f_all_rtpmaps = 8,
00514 sdp_f_print_prefix = 16,
00516 sdp_f_mode_0000 = 32,
00518 sdp_f_insane = 64,
00520 sdp_f_c_missing = 128,
00522 sdp_f_config = 256,
00524 sdp_f_mode_manual = 512,
00526 sdp_f_mode_always = 1024
00527 };
00528
00530 typedef struct sdp_parser_s sdp_parser_t;
00531 typedef sdp_parser_t *sdp_parser;
00532
00533 SOFIAPUBFUN sdp_parser_t *sdp_parse(su_home_t *,
00534 char const msg[], issize_t msgsize,
00535 int flags);
00536 SOFIAPUBFUN char const *sdp_parsing_error(sdp_parser_t *p);
00537 SOFIAPUBFUN sdp_session_t *sdp_session(sdp_parser_t *p);
00538 SOFIAPUBFUN void sdp_parser_free(sdp_parser_t *p);
00539
00540 SOFIAPUBFUN int sdp_sanity_check(sdp_parser_t *);
00541
00542 SOFIAPUBFUN su_home_t *sdp_parser_home(sdp_parser_t *);
00543
00544
00545
00547 typedef struct sdp_printer_s sdp_printer_t;
00548 typedef sdp_printer_t *sdp_printer;
00549
00550 SOFIAPUBFUN sdp_printer_t *sdp_print(su_home_t *, sdp_session_t const *,
00551 char msgbuf[], isize_t maxmsgsize,
00552 int flags);
00553 SOFIAPUBFUN char const *sdp_printing_error(sdp_printer_t *p);
00554 SOFIAPUBFUN char const *sdp_message(sdp_printer_t *p);
00555 SOFIAPUBFUN isize_t sdp_message_size(sdp_printer_t *p);
00556 SOFIAPUBFUN void sdp_printer_free(sdp_printer_t *p);
00557
00558 #define sdp_mapped_attribute_find sdp_attribute_mapped_find
00559 #define sdp_free_parser sdp_parser_free
00560 #define sdp_free_printer sdp_printer_free
00561
00562 SOFIA_END_DECLS
00563
00564 #endif