– Kamailio SIP Server –

/*
 * by Ovidiu Sas (work in progress)
 */

How to use the API

Here's an example on how to use the API provided by the OpenSER SDP parser:

First of all, we need to include the header file:

#include "../../parser/sdp/sdp.h"

Using the API:

/*
 * This is my method inside a module that handles the given sip message.
 */
void my_method(struct sip_msg* msg)
{
    sdp_session_cell_t *session;

    if (msg == NULL) {
        LM_ERR("null msg\n");
        return;
    }

    /* Check for SDP. */
    if (0 == parse_sdp(msg)) {
        LM_DBG("we have SDP!\n");
        /* Let's print the content of SDP via a DBG log.
         * Check openser logs to see the output.
         */

        /* initializing pointer to the first session
         * and start iterating through sessions.
         */
        session = msg->sdp->sessions;
        while (session) {
            print_sdp_session(session);
            session = session->next;
        }
    }
}

How to decipher the SDP

Here's an example of a parsed SDP:

Content-Type: multipart / mixed;boundary=unique-boundary-1
Content-Length:  346

Content-Type: application/SDP.
Content-Disposition: session

v=0
o=user1 53655765 2353687637 IN IP4 10.11.10.148
s=-
c=IN IP4 10.11.10.148
t=0 0
m=audio 6002 RTP/AVP 0 1 18
a=rtpmap:0 PCMU/8000
a=inactive

--unique-boundary-1
--unique-boundary-1
Content-Type: application/text

Hello

--unique-boundary-1--

And now the parsed structure.

Here are the debug logs:

DBG:core:print_sdp_session: ..session[0]:0x8174e50=>(nil) 'session' (1)=>0x8174e70
DBG:core:print_sdp_session: ....stream[0]:0x8174e70=>(nil) {0x817ce18} 'audio' '6002' 'RTP/AVP' '0 1 18' (3)=>0x817cdd8
DBG:core:print_sdp_session: ......payload[2]:0x817cdd8=>0x8174ef8 p_payload_attr[2]:0x817cdd8 '18' '' '' '' '' ''
DBG:core:print_sdp_session: ......payload[1]:0x8174ef8=>0x8174eb8 p_payload_attr[1]:0x8174ef8 '1' '' '' '' '' ''
DBG:core:print_sdp_session: ......payload[0]:0x8174eb8=>(nil) p_payload_attr[0]:0x8174eb8 '0' 'PCMU' '8000' '' 'inactive' ''

And how to decipher them:
We have one session. The session has one stream. The stream has three payloads:

  • session[0] with the Content-Disposition header set to “session”.
    • stream[0] identified by the “m=” line with the following parameters:
      • type: audio
      • port: 6002
      • transport: RTP/AVP
      • payloads: 0 1 18
        • payload[0] identified by id “0” with the following attributes:
          • codec name: PCMU
          • sample rate: 8000
          • attribute: inactive
        • payload[1] identified by id “1” with the following attributes:
        • payload[2]identified by id “18” with the following attributes: