Dear Kamailio'ns,

I am working on Kamailio server (V 4.1.2) with RTPproxy (1.2.1) integrated, in a standalone intranet infrastructure (no any connection with internet).
I dont have any NAT settings in my network set-up. even though i will not get Audio/video calls through some times. So in that concern I have installed RTPproxy, now all the audio/Video calls are fine (with some Pixelled). I have the Following Kamailio configuration script, in which it suppose to invoke RTPproxy service when the SIP clients behind NAT. But every time when i do Audio/Video calls, they are proxying through RTPproxy server only.
I analysed SIP captures of Audio/video call, i didnt found any IP/port changes in the whole SIP session and with this i assumed that there is no NAT issue in my Network.
But why all the Audio/Video calls are proxying through RTPproxy everytime ?

Is there any Wrong placement of function call in Kamailio configuration script (below) ?
#-----------------------------------------------------------------
#!ifdef WITH_NAT
# ----- rtpproxy params -----
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")

# ----- nathelper params -----
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", "sip:pinger@192.168.2.52")
modparam("nathelper", "sipping_method", "INFO")

# ----- NAT_traversal -----
modparam("nat_traversal", "keepalive_interval", 60)
modparam("nat_traversal", "keepalive_method", "NOTIFY")
modparam("nat_traversal", "keepalive_state_file", "/var/run/kamailio/keepalive_state")

# ----- params needed for NAT traversal in other modules -----
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", 6)
#!endif

#Routing Script
# -----------------------------------------------------------------
# Sanity Check Section
# -----------------------------------------------------------------
route {
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                break;
        };
    #if (msg:len > max_len) {
        if (msg:len >=  8192 ) {
                sl_send_reply("513", "Message too big");
                break;
        };


# -----------------------------------------------------------------
# Record Route Section
# -----------------------------------------------------------------
    #if (method!="REGISTER") {
    if (!method=="REGISTER") {   
    record_route();
    };
    if (method=="BYE" || method=="CANCEL") {
#    unforce_rtp_proxy();
    rtpproxy_answer();
    }

# -----------------------------------------------------------------
# Loose Route Section
# -----------------------------------------------------------------
    if (loose_route()) {

    if ((method=="INVITE" || method=="REFER") && !has_totag()) {
    sl_send_reply("403", "Forbidden");
    break;
    };

    if (method=="INVITE") {
    if (!proxy_authorize("192.168.2.52","subscriber")) {
#    proxy_challenge("","0");
    proxy_challenge("192.168.2.52", "0");
#    break;
    }

    else if (!check_from()) {
    sl_send_reply("403", "Use From=ID");
    break;
    };

    consume_credentials();
    if (nat_uac_test("19")) {
    setflag(6);
    force_rport();
    fix_nated_contact();
    };
    rtpproxy_offer("l");
    };
    route(1);
    break;
    };

# -----------------------------------------------------------------
# Call Type Processing Section
# -----------------------------------------------------------------
#    if (uri!=myself) {   
    if (!uri==myself) {
    route(4);

    route(1);
    break;
    };

    if (method=="ACK") {
    route(1);
    break;
    }

    if (method=="CANCEL") {
    route(1);
    break;
    }

    else if (method=="INVITE") {
    route(3);
    break;
    }
    else if (method=="REGISTER") {
    route(2);
    break;
    };

    lookup("aliases");
    if (uri!=myself) {
    route(4);

    route(1);
    break;
    };

    if (!lookup("location")) {
    sl_send_reply("404", "User Not Found");
    break;
    };
    route(1);
    }

# -----------------------------------------------------------------
# Default Message Handler
# -----------------------------------------------------------------
route[1] {
    t_on_reply("1");

    if (!t_relay()) {

    if (method=="INVITE" && isflagset(6)) {
    rtpproxy_answer();;
    };

    sl_reply_error();
    };
    }

# -----------------------------------------------------------------
# REGISTER Message Handler
# -----------------------------------------------------------------
route[2] {
    if (!search("^Contact:[ ]*\*") && nat_uac_test("19")) {
    setflag(6);
    fix_nated_register();
    force_rport();
    };
    sl_send_reply("100", "Trying");

    if (!www_authorize("192.168.2.52","subscriber")) {
    www_challenge("192.168.2.52","0");
    break;
    };

    if (!check_to()) {
    sl_send_reply("401", "Unauthorized");
    break;
    };

    consume_credentials();
    if (!save("location")) {
    sl_reply_error();
    };
    }

# -----------------------------------------------------------------
# INVITE Message Handler
# -----------------------------------------------------------------
route[3] {
    if (!proxy_authorize("192.168.2.52","subscriber")) {
    proxy_challenge("192.168.2.52","0");
    break;
    }
    else if (!check_from()) {
    sl_send_reply("403", "Use From=ID");
    break;
    };
    consume_credentials();
    if (nat_uac_test("19")) {
    setflag(6);
    }

    lookup("aliases");
    if (uri!=myself) {
    route(4);

    route(1);
    break;
    };

    if (!lookup("location")) {
    sl_send_reply("404", "User Not Found");
    break;
    };

    route(4);
    route(1);
    }

# -----------------------------------------------------------------
# NAT Traversal Section
# -----------------------------------------------------------------
route[4] {
    if (isflagset(6)) {
    force_rport();
    fix_nated_contact();
#    force_rtp_proxy();
    rtpproxy_offer();
    }
    }

onreply_route[1] {
    if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {
    if (!search("^Content-Length:[ ]*0")) {
#    force_rtp_proxy();
    rtpproxy_offer();
    };
    };

    if (nat_uac_test("1")) {
    fix_nated_contact();
    };
  }

Please find the Attachment for Tcpdump based Video call Sip capture for your better Understanding.

PS: Both Kamailio and RTPproxy are running on same IP (host), i.e 192.168.2.52.

Please anybody help me in resolving this issue.

Any help will greatly appreciate.

Regards,
Ravi.