/*
* 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:
* [b]session[0][/b] with the Content-Disposition header set to "[b]session[/b]".
** [b]stream[0][/b] identified by the "[b]m=[/b]" line with the following parameters:
*** type: [b]audio[/b]
*** port: [b]6002[/b]
*** transport: [b]RTP/AVP[/b]
*** payloads: [b]0 1 18[/b]
**** [b]payload[0][/b] identified by id "[b]0[/b]" with the following attributes:
***** codec name: [b]PCMU[/b]
***** sample rate: [b]8000[/b]
***** attribute: [b]inactive[/b]
**** [b]payload[1][/b] identified by id "[b]1[/b]" with the following attributes:
**** [b]payload[2][/b]identified by id "[b]18[/b]" with the following attributes: