MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_sdp_session

Function parse_sdp_session

parser/sdp/sdp.c:408–677  ·  view source on GitHub ↗

* SDP parser method. */

Source from the content-addressed store, hash-verified

406 * SDP parser method.
407 */
408int parse_sdp_session(str *sdp_body, int session_num, str *cnt_disp, sdp_info_t* _sdp)
409{
410 str body = *sdp_body;
411 str sdp_ip = {NULL,0};
412 str sdp_media, sdp_port, sdp_transport, sdp_payload;
413 str payload;
414 str rtp_payload, rtp_enc, rtp_clock, rtp_params;
415 int is_rtp;
416 char *bodylimit;
417 char *v1p, *o1p, *m1p, *m2p, *c1p, *c2p, *a1p, *a2p, *b1p;
418 str tmpstr1,custom_attr;
419 int stream_num, payloadnum, pf;
420 sdp_session_cell_t *session;
421 sdp_stream_cell_t *stream;
422 sdp_payload_attr_t *payload_attr;
423 int parse_payload_attr;
424 str fmtp_string;
425
426 /*
427 * Parsing of SDP body.
428 * Each session starts with v-line and each session may contain a few
429 * media descriptions (each starts with m-line).
430 * We have to change ports in m-lines, and also change IP addresses in
431 * c-lines which can be placed either in session header (fallback for
432 * all medias) or media description.
433 * Ports should be allocated for any media. IPs all should be changed
434 * to the same value (RTP proxy IP), so we can change all c-lines
435 * unconditionally.
436 */
437 bodylimit = body.s + body.len;
438 if (body.len < 2) {
439 LM_ERR("body too short!\n");
440 return -1;
441 }
442 v1p = body.s;
443 /* skip over the first initial \r\n (optional) */
444 if (*v1p == '\r' || *v1p == '\n')
445 v1p++;
446 if (*v1p == '\r' || *v1p == '\n')
447 v1p++;
448 if (v1p + 1 >= bodylimit) {
449 LM_ERR("body too short %ld!\n", (long)(bodylimit - v1p));
450 return -1;
451 }
452 if (*v1p != 'v' || *(v1p+1) != '=') {
453 LM_ERR("invalid SDP start: [%c%c]\n", *v1p, *(v1p + 1));
454 return -1;
455 }
456 /* get session origin */
457 o1p = find_sdp_line(v1p, bodylimit, 'o');
458 if (o1p == NULL) {
459 LM_ERR("no o= in session\n");
460 return -1;
461 }
462 /* Have this session media description? */
463 m1p = find_sdp_line(o1p, bodylimit, 'm');
464 if (m1p == NULL) {
465 LM_ERR("no m= in session\n");

Callers 12

tr_eval_sdpFunction · 0.85
b2b_sdp_client_syncFunction · 0.85
b2b_sdp_server_inviteFunction · 0.85
b2b_sdp_demuxFunction · 0.85
rtpproxy_gen_sdp_mediaFunction · 0.85
sngtc_callee_answerFunction · 0.85
sdp_get_hold_bodyFunction · 0.85
call_get_hold_bodyFunction · 0.85
parse_sdpFunction · 0.85

Calls 15

find_sdp_lineFunction · 0.85
add_sdp_sessionFunction · 0.85
extract_mediaipFunction · 0.85
extract_bwidthFunction · 0.85
find_next_sdp_lineFunction · 0.85
add_sdp_attrFunction · 0.85
extract_media_attrFunction · 0.85
add_sdp_streamFunction · 0.85
eat_token_endFunction · 0.85
add_sdp_payloadFunction · 0.85
eat_space_endFunction · 0.85
init_p_payload_attrFunction · 0.85

Tested by

no test coverage detected