sofia-sip/sdp.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Sofia-SIP package
00003  *
00004  * Copyright (C) 2005 Nokia Corporation.
00005  *
00006  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
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                       
00233 } sdp_media_e;
00234 
00236 typedef enum
00237 {
00238   sdp_proto_x = 0,                      
00239   sdp_proto_tcp = 6,                    
00240   sdp_proto_udp = 17,                   
00241   sdp_proto_rtp = 256,                  
00242   sdp_proto_srtp = 257,                 
00243   sdp_proto_tls = 511,                  
00244   sdp_proto_any = 512                   
00245 } sdp_proto_e;
00246 
00248 typedef enum {
00249   sdp_inactive = 0, 
00250   sdp_sendonly = 1, 
00251   sdp_recvonly = 2, 
00252   sdp_sendrecv = sdp_sendonly | sdp_recvonly
00253 } sdp_mode_t;
00254 
00265 struct sdp_media_s
00266 {
00267   int               m_size;             
00268   sdp_media_t      *m_next;             
00269   sdp_session_t    *m_session;          
00271   sdp_media_e       m_type;             
00272   sdp_text_t       *m_type_name;        
00273   unsigned long     m_port;             
00274   unsigned long     m_number_of_ports;  
00275   sdp_proto_e       m_proto;            
00276   sdp_text_t       *m_proto_name;       
00277   sdp_list_t       *m_format;           
00278   sdp_rtpmap_t     *m_rtpmaps;          
00279   sdp_text_t       *m_information;      
00280   sdp_connection_t *m_connections;      
00281   sdp_bandwidth_t  *m_bandwidths;       
00282   sdp_key_t        *m_key;              
00283   sdp_attribute_t  *m_attributes;       
00285   void             *m_user;             
00288   unsigned          m_rejected : 1;     
00290   /* sdp_mode_t */ unsigned m_mode : 2;
00291   unsigned          : 0;
00292 };
00293 
00295 struct sdp_list_s
00296 {
00297   int              l_size;              
00298   sdp_list_t      *l_next;              
00299   sdp_text_t      *l_text;              
00300 };
00301 
00311 struct sdp_rtpmap_s {
00312   int            rm_size;               
00313   sdp_rtpmap_t  *rm_next;               
00314   sdp_text_t    *rm_encoding;           
00315   unsigned long  rm_rate;               
00316   sdp_text_t    *rm_params;             
00317   sdp_text_t    *rm_fmtp;               
00318   unsigned       rm_predef : 1;         
00319   unsigned       rm_pt : 7;             
00320   unsigned       rm_any : 1;            
00321   int       :0;
00322 };
00323 
00324 SOFIAPUBVAR sdp_rtpmap_t const * const sdp_rtpmap_well_known[128];
00325 
00327 SOFIAPUBFUN sdp_session_t *sdp_session_dup(su_home_t *, sdp_session_t const *);
00328 
00330 SOFIAPUBFUN
00331 sdp_origin_t    *sdp_origin_dup(su_home_t *, sdp_origin_t const *);
00332 
00334 SOFIAPUBFUN
00335 sdp_connection_t *sdp_connection_dup(su_home_t *home, sdp_connection_t const *);
00336 
00338 SOFIAPUBFUN
00339 sdp_bandwidth_t  *sdp_bandwidth_dup(su_home_t *home, sdp_bandwidth_t const *);
00340 
00342 SOFIAPUBFUN
00343 sdp_time_t       *sdp_time_dup(su_home_t *home, sdp_time_t const *);
00344 
00346 SOFIAPUBFUN
00347 sdp_repeat_t     *sdp_repeat_dup(su_home_t *home, sdp_repeat_t const *);
00348 
00350 SOFIAPUBFUN
00351 sdp_zone_t       *sdp_zone_dup(su_home_t *home, sdp_zone_t const *);
00352 
00354 SOFIAPUBFUN
00355 sdp_key_t        *sdp_key_dup(su_home_t *home, sdp_key_t const *);
00356 
00358 SOFIAPUBFUN
00359 sdp_attribute_t  *sdp_attribute_dup(su_home_t *home, sdp_attribute_t const *);
00360 
00362 SOFIAPUBFUN
00363 sdp_media_t *sdp_media_dup(su_home_t *, sdp_media_t const *,
00364                            sdp_session_t *);
00365 
00367 SOFIAPUBFUN
00368 sdp_media_t *sdp_media_dup_all(su_home_t *, sdp_media_t const *,
00369                                sdp_session_t *);
00370 
00372 SOFIAPUBFUN
00373 sdp_list_t       *sdp_list_dup(su_home_t *home, sdp_list_t const *);
00374 
00376 SOFIAPUBFUN
00377 sdp_rtpmap_t     *sdp_rtpmap_dup(su_home_t *home, sdp_rtpmap_t const *);
00378 
00380 SOFIAPUBFUN int sdp_session_cmp(sdp_session_t const *a,
00381                                 sdp_session_t const *b);
00382 
00384 SOFIAPUBFUN int sdp_origin_cmp(sdp_origin_t const *a,
00385                                sdp_origin_t const *b);
00386 
00388 SOFIAPUBFUN int sdp_connection_cmp(sdp_connection_t const *,
00389                                    sdp_connection_t const *b);
00390 
00392 SOFIAPUBFUN int sdp_bandwidth_cmp(sdp_bandwidth_t const *a,
00393                                   sdp_bandwidth_t const *b);
00394 
00396 SOFIAPUBFUN int sdp_time_cmp(sdp_time_t const *a, sdp_time_t const *b);
00397 
00398 /* Compare two repeat (r=) fields */
00399 SOFIAPUBFUN int sdp_repeat_cmp(sdp_repeat_t const *a, sdp_repeat_t const *b);
00400 
00401 /* Compare two zone (z=) fields */
00402 SOFIAPUBFUN int sdp_zone_cmp(sdp_zone_t const *a, sdp_zone_t const *b);
00403 
00405 SOFIAPUBFUN int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b);
00406 
00408 SOFIAPUBFUN int sdp_attribute_cmp(sdp_attribute_t const *,
00409                                   sdp_attribute_t const *);
00410 
00412 SOFIAPUBFUN int sdp_media_cmp(sdp_media_t const *, sdp_media_t const *);
00413 
00415 SOFIAPUBFUN int sdp_rtpmap_cmp(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b);
00416 
00418 SOFIAPUBFUN int sdp_list_cmp(sdp_list_t const *a, sdp_list_t const *b);
00419 
00421 SOFIAPUBFUN sdp_connection_t *sdp_media_connections(sdp_media_t const *m);
00422 
00424 SOFIAPUBFUN int sdp_media_has_rtp(sdp_media_t const *m);
00425 
00427 SOFIAPUBFUN void sdp_media_type(sdp_media_t *m, char const *s);
00428 
00430 SOFIAPUBFUN void sdp_media_transport(sdp_media_t *m, char const *s);
00431 
00433 SOFIAPUBFUN sdp_attribute_t  *sdp_attribute_find(sdp_attribute_t const *a,
00434                                                  char const *name);
00435 
00437 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_find2(sdp_attribute_t const *a, 
00438                                                  sdp_attribute_t const *a2, 
00439                                                  char const *name);
00440 
00442 SOFIAPUBFUN sdp_mode_t sdp_attribute_mode(sdp_attribute_t const *a,
00443                                           sdp_mode_t defmode);
00444 
00446 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_by_mode(su_home_t *, 
00447                                                    sdp_mode_t mode);
00448 
00450 SOFIAPUBFUN 
00451 sdp_attribute_t *sdp_attribute_mapped_find(sdp_attribute_t const *a, 
00452                                            char const *name, 
00453                                            int pt, char **return_result);
00454 
00456 SOFIAPUBFUN void sdp_attribute_append(sdp_attribute_t **list, 
00457                           sdp_attribute_t const *a);
00458 
00460 SOFIAPUBFUN int sdp_attribute_replace(sdp_attribute_t **list, 
00461                                       sdp_attribute_t *a,
00462                                       sdp_attribute_t **return_replaced);
00463 
00465 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_remove(sdp_attribute_t **list, 
00466                                                   char const *name);
00467 
00468 /* Return 1 if m= line struct matches with given type and name */
00469 SOFIAPUBFUN unsigned sdp_media_match(sdp_media_t const *m,
00470                                      sdp_media_e type,
00471                                      sdp_text_t *type_name,
00472                                      sdp_proto_e proto,
00473                                      sdp_text_t *proto_name);
00474 
00475 SOFIAPUBFUN unsigned sdp_media_match_with(sdp_media_t const *a,
00476                                           sdp_media_t const *b);
00477 
00479 SOFIAPUBFUN unsigned sdp_media_count(sdp_session_t const *sdp,
00480                                      sdp_media_e type,
00481                                      sdp_text_t *type_name,
00482                                      sdp_proto_e proto,
00483                                      sdp_text_t *proto_name);
00484 
00485 SOFIAPUBFUN unsigned sdp_media_count_with(sdp_session_t const *sdp,
00486                                           sdp_media_t const *m0);
00487 
00489 SOFIAPUBFUN int sdp_media_uses_rtp(sdp_media_t const *m);
00490 
00492 SOFIAPUBFUN int sdp_rtpmap_match(sdp_rtpmap_t const *, sdp_rtpmap_t const *);
00493 
00495 SOFIAPUBFUN sdp_rtpmap_t *sdp_rtpmap_find_matching(sdp_rtpmap_t const *list,
00496                                                    sdp_rtpmap_t const *rm);
00497 
00498 /* ======================================================================== */
00499 
00501 enum sdp_parse_flags_e {
00503   sdp_f_strict = 1,
00505   sdp_f_anynet = 2,             
00507   sdp_f_realloc = 4,
00509   sdp_f_all_rtpmaps = 8,
00511   sdp_f_print_prefix = 16,
00513   sdp_f_mode_0000 = 32,
00515   sdp_f_insane = 64,
00517   sdp_f_c_missing = 128,
00519   sdp_f_config = 256,
00521   sdp_f_mode_manual = 512,
00523   sdp_f_mode_always = 1024
00524 };
00525 
00527 typedef struct sdp_parser_s sdp_parser_t;
00528 typedef sdp_parser_t  *sdp_parser;
00529 
00530 SOFIAPUBFUN sdp_parser_t *sdp_parse(su_home_t *,
00531                                     char const msg[], int msgsize, int flags);
00532 SOFIAPUBFUN char const *sdp_parsing_error(sdp_parser_t *p);
00533 SOFIAPUBFUN sdp_session_t *sdp_session(sdp_parser_t *p);
00534 SOFIAPUBFUN void sdp_parser_free(sdp_parser_t *p);
00535 
00536 SOFIAPUBFUN int sdp_sanity_check(sdp_parser_t *);
00537 
00538 SOFIAPUBFUN su_home_t *sdp_parser_home(sdp_parser_t *);
00539 
00540 /* ======================================================================== */
00541 
00543 typedef struct sdp_printer_s sdp_printer_t;
00544 typedef sdp_printer_t *sdp_printer;
00545 
00546 SOFIAPUBFUN sdp_printer_t *sdp_print(su_home_t *, sdp_session_t const *session, 
00547                                      char msgbuf[], int maxmsgsize, int flags);
00548 SOFIAPUBFUN char const *sdp_printing_error(sdp_printer_t *p);
00549 SOFIAPUBFUN char const *sdp_message(sdp_printer_t *p);
00550 SOFIAPUBFUN int   sdp_message_size(sdp_printer_t *p);
00551 SOFIAPUBFUN void sdp_printer_free(sdp_printer_t *p);
00552 
00553 #define sdp_mapped_attribute_find sdp_attribute_mapped_find
00554 #define sdp_free_parser  sdp_parser_free
00555 #define sdp_free_printer sdp_printer_free
00556 
00557 SOFIA_END_DECLS
00558 
00559 #endif /* SDP_H */

Sofia-SIP 1.12.1 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.