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

Function sdp_ops_parse_lines

sdp_ops.c:395–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393
394
395int sdp_ops_parse_lines(struct sdp_body_part_ops *ops, str *body)
396{
397 char *p, *lim = body->s + body->len, _sep[2], sep, *start;
398 int sep_len = 1, i = 0;
399
400 if (!sdp_detect_line_sep(body, _sep, &sep_len)) {
401 LM_ERR("failed to detect SDP separator, first 50B: '%.*s'\n",
402 body->len >= 50 ? 50:body->len, body->s);
403 return -1;
404 }
405
406 sep = _sep[0];
407 start = body->s;
408 for (p = start; p < lim; p++) {
409 if (*p != sep || (sep_len == 2 && p < (lim-1) && *(p+1) != '\n'))
410 continue;
411
412 if (i >= SDP_MAX_LINES) {
413 LM_ERR("SDP body exceeds maximum line count (%d)\n",
414 SDP_MAX_LINES);
415 return -1;
416 }
417
418 /* lines are stored *without* the ending separator */
419 ops->lines[i].line.s = start;
420 ops->lines[i].line.len = p - start;
421 ops->lines[i++].newbuf = 0;
422
423 start = p + sep_len;
424 }
425
426 /* edge-case: the very last SDP line does not include a separator... */
427 if (start < lim) {
428 if (i >= SDP_MAX_LINES) {
429 LM_ERR("SDP body exceeds maximum line count (%d)\n",
430 SDP_MAX_LINES);
431 return -1;
432 }
433
434 ops->lines[i].line.s = start;
435 ops->lines[i].line.len = p - start;
436 ops->lines[i++].newbuf = 0;
437 ops->flags |= SDP_OPS_FL_NO_LLF;
438 }
439
440 LM_DBG("parsed %d SDP lines in total\n", i);
441 ops->lines_sz = i;
442
443 memcpy(ops->sep, _sep, sep_len);
444 ops->sep_len = sep_len;
445
446 return 0;
447}
448
449#define first_part_by_mime( _part_start, _part_end, _mime) \
450 do {\

Callers 7

pv_get_sdp_lineFunction · 0.85
pv_set_sdp_lineFunction · 0.85
pv_get_sdp_streamFunction · 0.85
pv_set_sdp_streamFunction · 0.85
pv_get_sdp_stream_idxFunction · 0.85
pv_get_sdp_sessionFunction · 0.85
pv_set_sdp_sessionFunction · 0.85

Calls 1

sdp_detect_line_sepFunction · 0.85

Tested by

no test coverage detected