Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
development:sdp-parsing [2011/08/15 12:07] – 109.254.49.8 | development:sdp-parsing [2012/03/22 12:33] (current) – removed spam 80.250.1.245 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | /* | ||
+ | * 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 " | ||
+ | </ | ||
+ | |||
+ | 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(" | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | /* Check for SDP. */ | ||
+ | if (0 == parse_sdp(msg)) { | ||
+ | LM_DBG(" | ||
+ | /* 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-> | ||
+ | while (session) { | ||
+ | print_sdp_session(session); | ||
+ | session = session-> | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== How to decipher the SDP ===== | ||
+ | |||
+ | Here's an example of a parsed SDP: | ||
+ | |||
+ | < | ||
+ | Content-Type: | ||
+ | Content-Length: | ||
+ | |||
+ | Content-Type: | ||
+ | Content-Disposition: | ||
+ | |||
+ | 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: | ||
+ | |||
+ | Hello | ||
+ | |||
+ | --unique-boundary-1-- | ||
+ | </ | ||
+ | |||
+ | And now the parsed structure. | ||
+ | |||
+ | Here are the debug logs: | ||
+ | < | ||
+ | DBG: | ||
+ | DBG: | ||
+ | DBG: | ||
+ | DBG: | ||
+ | DBG: | ||
+ | </ | ||
+ | |||
+ | And how to decipher them: | ||
+ | We have one session. | ||
+ | * [b]session[0][/ | ||
+ | ** [b]stream[0][/ | ||
+ | *** type: [b]audio[/ | ||
+ | *** port: [b]6002[/b] | ||
+ | *** transport: [b]RTP/ | ||
+ | *** payloads: [b]0 1 18[/b] | ||
+ | **** [b]payload[0][/ | ||
+ | ***** codec name: [b]PCMU[/b] | ||
+ | ***** sample rate: [b]8000[/b] | ||
+ | ***** attribute: [b]inactive[/ | ||
+ | **** [b]payload[1][/ | ||
+ | **** [b]payload[2][/ | ||