rem: "port in media stream nr. %d\n", i+1);
add: "port in media stream nr. %d\n", i);
context: UseMediaProxy(struct sip_msg* msg, char* str1, char* str2){    str sdp, sessionIP, callId, fromDomain, toDomain, userAgent, tokens[64];    char *clientIP, *ptr, *command, *cmd, *result, *agent, *fromType, *toType;    int streamCount, i, port, count, cmdlen, success;    StreamInfo streams[64];    fromType = (isFromLocal(msg, NULL, NULL)>0) ? "local" : "remote";    if (msg->first_line.type == SIP_REQUEST &&        msg->first_line.u.request.method_value == METHOD_INVITE) {        cmd    = "request";        toType = (isDestinationLocal(msg, NULL, NULL)>0) ? "local" : "remote";    } else if (msg->first_line.type == SIP_REPLY) {        cmd    = "lookup";        toType = "unknown";    } else {        return -1;    }    if (!getCallId(msg, &callId)) {        LOG(L_ERR, "error: use_media_proxy(): can't get Call-Id\n");        return -1;    }    if (!getSDPMessage(msg, &sdp)) {        LOG(L_ERR, "error: use_media_proxy(): failed to get the SDP message\n");        return -1;    }    if (!getSessionLevelMediaIP(&sdp, &sessionIP)) {        LOG(L_ERR, "error: use_media_proxy(): error parsing the SDP message\n");        return -1;    }    streamCount = getMediaStreams(&sdp, &sessionIP, streams, 64);    if (streamCount == -1) {        LOG(L_ERR, "error: use_media_proxy(): can't extract media streams "            "from the SDP message\n");        return -1;    }    if (streamCount == 0) {        // there are no media streams. we have nothing to do.        return 1;    }    fromDomain = getFromDomain(msg);    toDomain   = getToDomain(msg);    //toDomain   = getDestinationDomain(msg); // can be called only for request(invite)    userAgent  = getUserAgent(msg);    clientIP = ip_addr2a(&msg->rcv.src_ip);    cmdlen = callId.len + strlen(clientIP) + fromDomain.len + toDomain.len +        userAgent.len*3 + 128;    for (i=0; i<streamCount; i++) {        cmdlen += streams[i].port.len + streams[i].ip.len + 2;    }    command = pkg_malloc(cmdlen);    if (!command) {        LOG(L_ERR, "error: use_media_proxy(): out of memory\n");        return -1;    }    count = sprintf(command, "%s %.*s", cmd, callId.len, callId.s);    for (i=0, ptr=command+count; i<streamCount; i++) {        char c = (i==0 ? ' ' : ',');        count = sprintf(ptr, "%c%.*s:%.*s", c,                        streams[i].ip.len, streams[i].ip.s,                        streams[i].port.len, streams[i].port.s);        ptr += count;    }    agent = encodeQuopri(userAgent);    snprintf(ptr, command + cmdlen - ptr, " %s %.*s %s %.*s %s %s flags=%s\n",             clientIP, fromDomain.len, fromDomain.s, fromType,             toDomain.len, toDomain.s, toType, agent,             isRTPAsymmetric(userAgent) ? "asymmetric" : "");    pkg_free(agent);    result = sendMediaproxyCommand(command);    pkg_free(command);    if (result == NULL)        return -1;    count = getTokens(result, tokens, sizeof(tokens)/sizeof(str));    if (count == 0) {        LOG(L_ERR, "error: use_media_proxy(): empty response from mediaproxy\n");        return -1;    } else if (count < streamCount+1) {        LOG(L_ERR, "error: use_media_proxy(): insufficient ports returned "            "from mediaproxy: got %d, expected %d\n", count-1, streamCount);        return -1;    }    if (sessionIP.s && !ISANYADDR(sessionIP)) {        success = replaceElement(msg, &sessionIP, &tokens[0]);        if (!success) {            LOG(L_ERR, "error: use_media_proxy(): failed to replace "                "session-level media IP in SDP body\n");            return -1;        }    }    for (i=0; i<streamCount; i++) {        // check. is this really necessary?        port = strtoint(&tokens[i+1]);        if (port <= 0 || port > 65535) {            LOG(L_ERR, "error: use_media_proxy(): invalid port returned "                "by mediaproxy: %.*s\n", tokens[i+1].len, tokens[i+1].s);            //return -1;            continue;        }        if (streams[i].port.len!=1 || streams[i].port.s[0]!='0') {            success = replaceElement(msg, &(streams[i].port), &tokens[i+1]);            if (!success) {                LOG(L_ERR, "error: use_media_proxy(): failed to replace "                    "port in media stream nr. %d\n", i+1);                return -1;            }        }        if (streams[i].localIP && !ISANYADDR(streams[i].ip)) {            success = replaceElement(msg, &(streams[i].ip), &tokens[0]);            if (!success) {                LOG(L_ERR, "error: use_media_proxy(): failed to replace "                    "IP address in media stream nr. %d\n", i+1);                return -1;            }        }    }    return 1;}