kamailio

change (just text in SDP) telephone-event/16000 to 8000 and back again


my sip partner does send sometimes in SDP:

v=0
o=HuaweiSoftx3000 69494235717543 69494235717543 IN IP4 18.8.14.12
s=-
c=IN IP4 18.8.14.12
t=0 0
m=audio 39204 RTP/AVP 96 98 8 99 100 104 0 97
a=rtpmap:96 AMR-WB/16000
a=rtpmap:8 PCMA/8000
a=rtpmap:104 telephone-event/16000

(there is no telephone-event/16000), we do expect a telephone-event/8000 so we change it (simply a text replace)

so we fix it - like this

route[FIXSDP] {
       if (has_body("application/sdp")) {
               if(subst("/event\/16000/event\/8000/")) {
                       xlog("L_INFO", "SDP SILLTFIXDTMF [$fU->$tU]");
               }
       }
}

it's about 20% of sip traffic.

but we want (need) to replace a 8000 coming back to this party in '200' messages to look like 16000, and only in those dialogs (other have a 8000 and work fine), any hints? (need to be stateful with this).


Solution

  • You should check textops module, it have many rewrite functions.

    For backwards you should use on_reply route. You may mark your calls using dialog and avpairs.