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_red                         
00234 } sdp_media_e;
00235 
00237 typedef enum
00238 {
00239   sdp_proto_x = 0,                      
00240   sdp_proto_tcp = 6,                    
00241   sdp_proto_udp = 17,                   
00242   sdp_proto_rtp = 256,                  
00243   sdp_proto_srtp = 257,                 
00244   sdp_proto_udptl = 258,                
00245   sdp_proto_tls = 511,                  
00246   sdp_proto_any = 512                   
00247 } sdp_proto_e;
00248 
00250 typedef enum {
00251   sdp_inactive = 0, 
00252   sdp_sendonly = 1, 
00253   sdp_recvonly = 2, 
00254   sdp_sendrecv = sdp_sendonly | sdp_recvonly
00255 } sdp_mode_t;
00256 
00267 struct sdp_media_s
00268 {
00269   int               m_size;             
00270   sdp_media_t      *m_next;             
00271   sdp_session_t    *m_session;          
00273   sdp_media_e       m_type;             
00274   sdp_text_t       *m_type_name;        
00275   unsigned long     m_port;             
00276   unsigned long     m_number_of_ports;  
00277   sdp_proto_e       m_proto;            
00278   sdp_text_t       *m_proto_name;       
00279   sdp_list_t       *m_format;           
00280   sdp_rtpmap_t     *m_rtpmaps;          
00281   sdp_text_t       *m_information;      
00282   sdp_connection_t *m_connections;      
00283   sdp_bandwidth_t  *m_bandwidths;       
00284   sdp_key_t        *m_key;              
00285   sdp_attribute_t  *m_attributes;       
00287   void             *m_user;             
00290   unsigned          m_rejected : 1;     
00292   /* sdp_mode_t */ unsigned m_mode : 2;
00293   unsigned          : 0;
00294 };
00295 
00297 struct sdp_list_s
00298 {
00299   int              l_size;              
00300   sdp_list_t      *l_next;              
00301   sdp_text_t      *l_text;              
00302 };
00303 
00313 struct sdp_rtpmap_s {
00314   int            rm_size;               
00315   sdp_rtpmap_t  *rm_next;               
00316   sdp_text_t    *rm_encoding;           
00317   unsigned long  rm_rate;               
00318   sdp_text_t    *rm_params;             
00319   sdp_text_t    *rm_fmtp;               
00320   unsigned       rm_predef : 1;         
00321   unsigned       rm_pt : 7;             
00322   unsigned       rm_any : 1;            
00323   int       :0;
00324 };
00325 
00326 SOFIAPUBVAR sdp_rtpmap_t const * const sdp_rtpmap_well_known[128];
00327 
00329 SOFIAPUBFUN sdp_session_t *sdp_session_dup(su_home_t *, sdp_session_t const *);
00330 
00332 SOFIAPUBFUN
00333 sdp_origin_t    *sdp_origin_dup(su_home_t *, sdp_origin_t const *);
00334 
00336 SOFIAPUBFUN
00337 sdp_connection_t *sdp_connection_dup(su_home_t *home, sdp_connection_t const *);
00338 
00340 SOFIAPUBFUN
00341 sdp_bandwidth_t  *sdp_bandwidth_dup(su_home_t *home, sdp_bandwidth_t const *);
00342 
00344 SOFIAPUBFUN
00345 sdp_time_t       *sdp_time_dup(su_home_t *home, sdp_time_t const *);
00346 
00348 SOFIAPUBFUN
00349 sdp_repeat_t     *sdp_repeat_dup(su_home_t *home, sdp_repeat_t const *);
00350 
00352 SOFIAPUBFUN
00353 sdp_zone_t       *sdp_zone_dup(su_home_t *home, sdp_zone_t const *);
00354 
00356 SOFIAPUBFUN
00357 sdp_key_t        *sdp_key_dup(su_home_t *home, sdp_key_t const *);
00358 
00360 SOFIAPUBFUN
00361 sdp_attribute_t  *sdp_attribute_dup(su_home_t *home, sdp_attribute_t const *);
00362 
00364 SOFIAPUBFUN
00365 sdp_media_t *sdp_media_dup(su_home_t *, sdp_media_t const *,
00366                            sdp_session_t *);
00367 
00369 SOFIAPUBFUN
00370 sdp_media_t *sdp_media_dup_all(su_home_t *, sdp_media_t const *,
00371                                sdp_session_t *);
00372 
00374 SOFIAPUBFUN
00375 sdp_list_t       *sdp_list_dup(su_home_t *home, sdp_list_t const *);
00376 
00378 SOFIAPUBFUN
00379 sdp_rtpmap_t     *sdp_rtpmap_dup(su_home_t *home, sdp_rtpmap_t const *);
00380 
00382 SOFIAPUBFUN int sdp_session_cmp(sdp_session_t const *a,
00383                                 sdp_session_t const *b);
00384 
00386 SOFIAPUBFUN int sdp_origin_cmp(sdp_origin_t const *a,
00387                                sdp_origin_t const *b);
00388 
00390 SOFIAPUBFUN int sdp_connection_cmp(sdp_connection_t const *,
00391                                    sdp_connection_t const *b);
00392 
00394 SOFIAPUBFUN int sdp_bandwidth_cmp(sdp_bandwidth_t const *a,
00395                                   sdp_bandwidth_t const *b);
00396 
00398 SOFIAPUBFUN int sdp_time_cmp(sdp_time_t const *a, sdp_time_t const *b);
00399 
00400 /* Compare two repeat (r=) fields */
00401 SOFIAPUBFUN int sdp_repeat_cmp(sdp_repeat_t const *a, sdp_repeat_t const *b);
00402 
00403 /* Compare two zone (z=) fields */
00404 SOFIAPUBFUN int sdp_zone_cmp(sdp_zone_t const *a, sdp_zone_t const *b);
00405 
00407 SOFIAPUBFUN int sdp_key_cmp(sdp_key_t const *a, sdp_key_t const *b);
00408 
00410 SOFIAPUBFUN int sdp_attribute_cmp(sdp_attribute_t const *,
00411                                   sdp_attribute_t const *);
00412 
00414 SOFIAPUBFUN int sdp_media_cmp(sdp_media_t const *, sdp_media_t const *);
00415 
00417 SOFIAPUBFUN int sdp_rtpmap_cmp(sdp_rtpmap_t const *a, sdp_rtpmap_t const *b);
00418 
00420 SOFIAPUBFUN int sdp_list_cmp(sdp_list_t const *a, sdp_list_t const *b);
00421 
00423 SOFIAPUBFUN sdp_connection_t *sdp_media_connections(sdp_media_t const *m);
00424 
00426 SOFIAPUBFUN int sdp_media_has_rtp(sdp_media_t const *m);
00427 
00429 SOFIAPUBFUN void sdp_media_type(sdp_media_t *m, char const *s);
00430 
00432 SOFIAPUBFUN void sdp_media_transport(sdp_media_t *m, char const *s);
00433 
00435 SOFIAPUBFUN sdp_attribute_t  *sdp_attribute_find(sdp_attribute_t const *a,
00436                                                  char const *name);
00437 
00439 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_find2(sdp_attribute_t const *a, 
00440                                                  sdp_attribute_t const *a2, 
00441                                                  char const *name);
00442 
00444 SOFIAPUBFUN sdp_mode_t sdp_attribute_mode(sdp_attribute_t const *a,
00445                                           sdp_mode_t defmode);
00446 
00448 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_by_mode(su_home_t *, 
00449                                                    sdp_mode_t mode);
00450 
00452 SOFIAPUBFUN 
00453 sdp_attribute_t *sdp_attribute_mapped_find(sdp_attribute_t const *a, 
00454                                            char const *name, 
00455                                            int pt, char **return_result);
00456 
00458 SOFIAPUBFUN void sdp_attribute_append(sdp_attribute_t **list, 
00459                           sdp_attribute_t const *a);
00460 
00462 SOFIAPUBFUN int sdp_attribute_replace(sdp_attribute_t **list, 
00463                                       sdp_attribute_t *a,
00464                                       sdp_attribute_t **return_replaced);
00465 
00467 SOFIAPUBFUN sdp_attribute_t *sdp_attribute_remove(sdp_attribute_t **list, 
00468                                                   char const *name);
00469 
00470 /* Return 1 if m= line struct matches with given type and name */
00471 SOFIAPUBFUN unsigned sdp_media_match(sdp_media_t const *m,
00472                                      sdp_media_e type,
00473                                      sdp_text_t *type_name,
00474                                      sdp_proto_e proto,
00475                                      sdp_text_t *proto_name);
00476 
00477 SOFIAPUBFUN unsigned sdp_media_match_with(sdp_media_t const *a,
00478                                           sdp_media_t const *b);
00479 
00481 SOFIAPUBFUN unsigned sdp_media_count(sdp_session_t const *sdp,
00482                                      sdp_media_e type,
00483                                      sdp_text_t *type_name,
00484                                      sdp_proto_e proto,
00485                                      sdp_text_t *proto_name);
00486 
00487 SOFIAPUBFUN unsigned sdp_media_count_with(sdp_session_t const *sdp,
00488                                           sdp_media_t const *m0);
00489 
00491 SOFIAPUBFUN int sdp_media_uses_rtp(sdp_media_t const *m);
00492 
00494 SOFIAPUBFUN int sdp_rtpmap_match(sdp_rtpmap_t const *, sdp_rtpmap_t const *);
00495 
00497 SOFIAPUBFUN sdp_rtpmap_t *sdp_rtpmap_find_matching(sdp_rtpmap_t const *list,
00498                                                    sdp_rtpmap_t const *rm);
00499 
00500 /* ======================================================================== */
00501 
00503 enum sdp_parse_flags_e {
00505   sdp_f_strict = 1,
00507   sdp_f_anynet = 2,             
00509   sdp_f_realloc = 4,
00511   sdp_f_all_rtpmaps = 8,
00513   sdp_f_print_prefix = 16,
00515   sdp_f_mode_0000 = 32,
00517   sdp_f_insane = 64,
00519   sdp_f_c_missing = 128,
00521   sdp_f_config = 256,
00523   sdp_f_mode_manual = 512,
00525   sdp_f_mode_always = 1024
00526 };
00527 
00529 typedef struct sdp_parser_s sdp_parser_t;
00530 typedef sdp_parser_t  *sdp_parser;
00531 
00532 SOFIAPUBFUN sdp_parser_t *sdp_parse(su_home_t *,
00533                                     char const msg[], issize_t msgsize,
00534                                     int flags);
00535 SOFIAPUBFUN char const *sdp_parsing_error(sdp_parser_t *p);
00536 SOFIAPUBFUN sdp_session_t *sdp_session(sdp_parser_t *p);
00537 SOFIAPUBFUN void sdp_parser_free(sdp_parser_t *p);
00538 
00539 SOFIAPUBFUN int sdp_sanity_check(sdp_parser_t *);
00540 
00541 SOFIAPUBFUN su_home_t *sdp_parser_home(sdp_parser_t *);
00542 
00543 /* ======================================================================== */
00544 
00546 typedef struct sdp_printer_s sdp_printer_t;
00547 typedef sdp_printer_t *sdp_printer;
00548 
00549 SOFIAPUBFUN sdp_printer_t *sdp_print(su_home_t *, sdp_session_t const *session, 
00550                                      char msgbuf[], isize_t maxmsgsize, int flags);
00551 SOFIAPUBFUN char const *sdp_printing_error(sdp_printer_t *p);
00552 SOFIAPUBFUN char const *sdp_message(sdp_printer_t *p);
00553 SOFIAPUBFUN isize_t sdp_message_size(sdp_printer_t *p);
00554 SOFIAPUBFUN void sdp_printer_free(sdp_printer_t *p);
00555 
00556 #define sdp_mapped_attribute_find sdp_attribute_mapped_find
00557 #define sdp_free_parser  sdp_parser_free
00558 #define sdp_free_printer sdp_printer_free
00559 
00560 SOFIA_END_DECLS
00561 
00562 #endif /* SDP_H */

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