sdp.h

00001 /*
00002  * $Id: sdp.h 4807 2008-09-02 15:00:48Z osas $
00003  *
00004  * SDP parser interface
00005  *
00006  * Copyright (C) 2008-2009 SOMA Networks, INC.
00007  * Copyright (C) 2010 VoIP Embedded, Inc
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions are met:
00011  * 
00012  *  1. Redistributions of source code must retain the above copyright notice,
00013  *  this list of conditions and the following disclaimer.
00014  *  2. Redistributions in binary form must reproduce the above copyright
00015  *  notice, this list of conditions and the following disclaimer in the
00016  *  documentation and/or other materials provided with the distribution.
00017  * 
00018  * THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY EXPRESS OR
00019  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00020  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00021  * EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00022  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00023  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00024  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00025  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00026  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00027  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  *
00029  */
00030 
00031 
00032 #ifndef SDP_H
00033 #define SDP_H
00034 
00035 #include "../msg_parser.h"
00036 
00037 typedef struct sdp_payload_attr {
00038         struct sdp_payload_attr *next;
00039         int payload_num; 
00040         str rtp_payload;
00041         str rtp_enc;
00042         str rtp_clock;
00043         str rtp_params;
00044         str fmtp_string;
00045 } sdp_payload_attr_t;
00046 
00047 typedef struct sdp_stream_cell {
00048         struct sdp_stream_cell *next;
00049         /* c=<network type> <address type> <connection address> */
00050         int pf;         
00051         str ip_addr;    
00052         int stream_num; 
00053         int is_rtp;     
00054         int is_on_hold; 
00055         /* m=<media> <port> <transport> <payloads> */
00056         str media;
00057         str port;
00058         str transport;
00059         str sendrecv_mode;
00060         str ptime;
00061         str payloads;
00062         int payloads_num;                         
00063         /* b=<bwtype>:<bandwidth> */
00064         str bw_type;                              
00067         str bw_width;                            
00068         /* RFC3605: Real Time Control Protocol (RTCP) attribute in Session Description Protocol (SDP) */
00069         /* a=rtcp: port  [nettype space addrtype space connection-address] CRLF */
00070         str rtcp_port;                            
00071         str path;                                 
00072         str max_size;                             
00073         str accept_types;                         
00074         str accept_wrapped_types;                 
00075         struct sdp_payload_attr **p_payload_attr; 
00076         struct sdp_payload_attr *payload_attr;
00077 } sdp_stream_cell_t;
00078 
00079 typedef struct sdp_session_cell {
00080         struct sdp_session_cell *next;
00081         int session_num;  
00082         str cnt_disp;     
00083         /* c=<network type> <address type> <connection address> */
00084         int pf;         
00085         str ip_addr;    
00086         /* o=<username> <session id> <version> <network type> <address type> <address> */
00087         int o_pf;       
00088         str o_ip_addr;  
00089         /* b=<bwtype>:<bandwidth> */
00090         str bw_type;      
00093         str bw_width;   
00094         int streams_num;  
00095         struct sdp_stream_cell*  streams;
00096 } sdp_session_cell_t;
00097 
00101 typedef struct sdp_info {
00102         msg_body_type_t type;
00103         free_msg_body_f free;
00104         str text; 
00105         int sessions_num;       
00106         int streams_num;  
00107         str raw_sdp;      /* Pointer to the Raw SDP (Might be embedded in multipart body) */
00108         struct sdp_session_cell *sessions;
00109 } sdp_info_t;
00110 
00111 
00112 /*
00113  * Parse SDP.
00114  */
00115 int parse_sdp(struct sip_msg* _m);
00116 
00120 int get_sdp_session_num(struct sip_msg* _m);
00124 int get_sdp_stream_num(struct sip_msg* _m);
00128 sdp_session_cell_t* get_sdp_session(struct sip_msg* _m, int session_num);
00132 sdp_session_cell_t* get_sdp_session_sdp(struct sdp_info* sdp, int session_num);
00133 
00137 sdp_stream_cell_t* get_sdp_stream(struct sip_msg* _m, int session_num, int stream_num);
00141 sdp_stream_cell_t* get_sdp_stream_sdp(struct sdp_info* sdp, int session_num, int stream_num);
00142 
00146 sdp_payload_attr_t* get_sdp_payload4payload(sdp_stream_cell_t *stream, str *rtp_payload);
00147 
00151 sdp_payload_attr_t* get_sdp_payload4index(sdp_stream_cell_t *stream, int index);
00152 
00158 void free_sdp(sdp_info_t** _sdp);
00159 
00160 
00166 void print_sdp(sdp_info_t* sdp, int log_level);
00172 void print_sdp_session(sdp_session_cell_t* sdp_session, int log_level);
00178 void print_sdp_stream(sdp_stream_cell_t *stream, int log_level);
00179 
00180 
00181 #endif /* SDP_H */