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

Function use_media_proxy

modules/mediaproxy/mediaproxy.c:1455–1744  ·  view source on GitHub ↗

ice_candidate_data: it carries data across the dialog when using engage_media_proxy: - priority: the priority that should be used for the ICE candidate -1: no candidate should be added. other: the specified type preference should be used for calculating - skip_next_reply: flag for knowing the fact that the next reply with SDP must be skipped because it is a reply to a re-INVITE or UPDATE *after* t

Source from the content-addressed store, hash-verified

1453// - skip_next_reply: flag for knowing the fact that the next reply with SDP must be skipped
1454// because it is a reply to a re-INVITE or UPDATE *after* the ICE negotiation
1455static int
1456use_media_proxy(struct sip_msg *msg, char *dialog_id, ice_candidate_data *ice_data)
1457{
1458 str callid, cseq, from_uri, to_uri, from_tag, to_tag, user_agent;
1459 str signaling_ip, media_relay, sdp, str_buf, tokens[MAX_STREAMS+1];
1460 str priority_str, candidate;
1461 char request[8192], media_str[4096], buf[128], *result, *type;
1462 int i, j, port, len, status;
1463 Bool removed_session_ip, have_sdp;
1464 SessionInfo session;
1465 StreamInfo stream;
1466
1467 if (msg == NULL)
1468 return -1;
1469
1470 if (msg->first_line.type == SIP_REQUEST) {
1471 type = "request";
1472 } else if (msg->first_line.type == SIP_REPLY) {
1473 if (ice_data != NULL && ice_data->skip_next_reply) {
1474 // we don't process replies to ICE negotiation end requests
1475 // (those containing a=remote-candidates)
1476 ice_data->skip_next_reply = False;
1477 return -1;
1478 }
1479 type = "reply";
1480 } else {
1481 return -1;
1482 }
1483
1484 if (get_callid(msg, &callid) < 0) {
1485 LM_ERR("failed to get Call-ID\n");
1486 return -1;
1487 }
1488
1489 if (!get_cseq_number(msg, &cseq)) {
1490 LM_ERR("failed to get CSeq\n");
1491 return -1;
1492 }
1493
1494 status = get_sdp_message(msg, &sdp);
1495 // status = -1 is error, -2 is missing SDP body
1496 if (status == -1 || (status == -2 && msg->first_line.type == SIP_REQUEST)) {
1497 return status;
1498 } else if (status == -2 && !(msg->REPLY_STATUS == 200 && get_method_from_reply(msg) == METHOD_INVITE)) {
1499 return -2;
1500 }
1501 have_sdp = (status == 1);
1502
1503 if (have_sdp) {
1504 if (msg->first_line.type == SIP_REQUEST && find_line_starting_with(&sdp, "a=remote-candidates", False)) {
1505 // we don't process requests with a=remote-candidates, this indicates the end of an ICE
1506 // negotiation and we must not mangle the SDP.
1507 if (ice_data != NULL) {
1508 ice_data->skip_next_reply = True;
1509 }
1510 return -1;
1511 }
1512

Callers 4

__dialog_requestsFunction · 0.85
__dialog_repliesFunction · 0.85
__tm_request_inFunction · 0.85
UseMediaProxyFunction · 0.85

Calls 15

get_callidFunction · 0.85
get_cseq_numberFunction · 0.85
get_sdp_messageFunction · 0.85
get_method_from_replyFunction · 0.85
find_line_starting_withFunction · 0.85
get_session_infoFunction · 0.85
get_from_uriFunction · 0.85
get_to_uriFunction · 0.85
get_user_agentFunction · 0.85
get_media_relayFunction · 0.85
get_tokensFunction · 0.85
replace_elementFunction · 0.85

Tested by

no test coverage detected