Returning to this issue(I didn't have enough time before, to continue with debug), I have configured the module debugger, in order to try see more information when kamailio executes the function "sdp remove codecs_by_id", and what i see is that the function is executed and the logs says that the function removes the codecs specified in SDP body, but in reality it doesn't happen, and there isn't any errors executing the function.
9(9082) DEBUG: <core> [db_res.c:92]: db_free_columns(): freeing result names at 0x7fe2174741f8
9(9082) DEBUG: <core> [db_res.c:97]: db_free_columns(): freeing result types at 0x7fe2174743c0
9(9082) DEBUG: <core> [db_res.c:52]: db_free_rows(): freeing 1 rows
9(9082) DEBUG: <core> [db_row.c:95]: db_free_row(): freeing row values at 0x7fe21765a298
9(9082) DEBUG: <core> [db_res.c:60]: db_free_rows(): freeing rows at 0x7fe21765a250
9(9082) DEBUG: <core> [db_res.c:134]: db_free_result(): freeing result set at 0x7fe217480910
9(9082) DEBUG: registrar [lookup.c:196]: lookup_helper(): contact for [302@teste.demo.pt] found by address 9(9082) DEBUG: <core> [parser/parse_rr.c:452]: get_path_dst_uri(): path for branch: '<sip:lb@10.0.20.103:5062;lr;received=sip:100.64.250.254:46572>' 9(9082) INFO: <script>: Internal call's for account teste.demo.pt - R=sip:302@192.168.10.197:5060;line=y8nryy19 ID=313433363433323332313432323132-2dqr4288p1lg 9(9082) DEBUG: tm [t_lookup.c:1312]: t_newtran(): DEBUG: t_newtran: msg id=1 , global msg id=1 , T on entrance=(nil)
9(9082) DEBUG: tm [t_lookup.c:466]: t_lookup_request(): t_lookup_request: start searching: hash=51835, isACK=0
9(9082) DEBUG: tm [t_lookup.c:424]: matching_3261(): DEBUG: RFC3261 transaction matching failed
9(9082) DEBUG: tm [t_lookup.c:648]: t_lookup_request(): DEBUG: t_lookup_request: no transaction found
9(9082) DEBUG: tm [t_hooks.c:358]: run_reqin_callbacks_internal(): DBG: trans=0x7fe1fd3e5c68, callback type 1, id 0 entered
9(9082) DEBUG: tm [t_hooks.c:358]: run_reqin_callbacks_internal(): DBG: trans=0x7fe1fd3e5c68, callback type 1, id 0 entered
9(9082) DEBUG: dialog [dlg_hash.c:614]: dlg_lookup(): ref dlg 0x7fe1fd3d6ed8 with 1 -> 2
9(9082) DEBUG: dialog [dlg_hash.c:616]: dlg_lookup(): dialog id=2457 found on entry 2631
9(9082) DEBUG: dialog [dlg_handlers.c:721]: dlg_onreq(): dialog added to tm callbacks
9(9082) DEBUG: dialog [dlg_hash.c:832]: dlg_unref(): unref dlg 0x7fe1fd3d6ed8 with 1 -> 1
9(9082) DEBUG: tm [t_hooks.c:358]: run_reqin_callbacks_internal(): DBG: trans=0x7fe1fd3e5c68, callback type 1, id 0 entered
9(9082) DEBUG: <core> [md5utils.c:67]: MD5StringArray(): MD5 calculated: a95682a5a071560d00ceb5cf18f5bbb1
9(9082) DEBUG: <core> [forward.c:702]: update_sock_struct_from_via(): trying SRV lookup
9082(9082) DEBUG: debugger [debugger_api.c:266]: dbg_msgid_filter(): process_no:9082 indx:9
9082(9082) DEBUG: debugger [debugger_api.c:280]: dbg_msgid_filter(): msg->id:1 msgid_base:0 -> 1
9(9082) DEBUG: <script>: new branch [0] to sip:302@192.168.10.197:5060;line=y8nryy19
9(9082) INFO: <script>: [Callflow] ------------------------------------------codec remove 3,0,9------------------------------------------- R=sip:302@192.168.10.197:5060;line=y8nryy19 ID=313433363433323332313432323132-2dqr4288p1lg
9(9082) DEBUG: textops [textops.c:2473]: has_body_f(): content type is 196611
9(9082) DEBUG: sdpops [sdpops_mod.c:339]: sdp_remove_codecs_by_id(): attempting to remove codecs from sdp: [3,0,9]
9(9082) DEBUG: sdpops [sdpops_mod.c:354]: sdp_remove_codecs_by_id(): stream 0 of 0 - payloads [9 0 8 3 99 112 18 101]
9(9082) DEBUG: sdpops [sdpops_mod.c:365]: sdp_remove_codecs_by_id(): codecs [9 0 8 3 99 112 18 101] - remove [3]
9(9082) DEBUG: sdpops [sdpops_mod.c:289]: sdp_remove_str_codec_id(): found codec [3] inside [9 0 8 3 99 112 18 101]
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 101/telephone-event
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 18/G729
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 112/AAL2-G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 99/G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 3/GSM
9(9082) DEBUG: sdpops [sdpops_mod.c:197]: sdp_remove_str_codec_id_attrs(): removing line: a=rtpmap:3 GSM/8000
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 8/PCMA
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 0/PCMU
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 9/G722
9(9082) DEBUG: sdpops [sdpops_mod.c:365]: sdp_remove_codecs_by_id(): codecs [9 0 8 3 99 112 18 101] - remove [0]
9(9082) DEBUG: sdpops [sdpops_mod.c:289]: sdp_remove_str_codec_id(): found codec [0] inside [9 0 8 3 99 112 18 101]
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 101/telephone-event
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 18/G729
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 112/AAL2-G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 99/G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 3/GSM
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 8/PCMA
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 0/PCMU
9(9082) DEBUG: sdpops [sdpops_mod.c:197]: sdp_remove_str_codec_id_attrs(): removing line: a=rtpmap:0 PCMU/8000
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 9/G722
9(9082) DEBUG: sdpops [sdpops_mod.c:365]: sdp_remove_codecs_by_id(): codecs [9 0 8 3 99 112 18 101] - remove [9]
9(9082) DEBUG: sdpops [sdpops_mod.c:289]: sdp_remove_str_codec_id(): found codec [9] inside [9 0 8 3 99 112 18 101]
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 101/telephone-event
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 18/G729
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 112/AAL2-G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 99/G726-32
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 3/GSM
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 8/PCMA
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 0/PCMU
9(9082) DEBUG: sdpops [sdpops_mod.c:190]: sdp_remove_str_codec_id_attrs(): a= ... for codec 9/G722
9(9082) DEBUG: sdpops [sdpops_mod.c:197]: sdp_remove_str_codec_id_attrs(): removing line: a=rtpmap:9 G722/8000
Record-Route: <sip:10.0.20.103:5062;r2=on;lr=on;ftag=etq6ixm8l0;nat=yes;lb=yes>
Record-Route: <sip:100.64.250.5;r2=on;lr=on;ftag=etq6ixm8l0;nat=yes;lb=yes>
Via: SIP/2.0/UDP 10.0.20.103:5062;branch=z9hG4bKb7ac.4d1b542c3b99d7410acbc985476e83d2.0
Via: SIP/2.0/UDP 192.168.30.107:5060;received=100.64.250.254;branch=z9hG4bK-k9wsyxdyb3sl;rport=5060
Call-ID: 313433363433323332313432323132-2dqr4288p1lg
CSeq: 2 INVITE
Max-Forwards: 68
Contact: <sip:301@192.168.30.107:5060;alias=100.64.250.254~5060~1;line=lb5k2cyy>;reg-id=1
X-Serialnumber: 000413262FA1
P-Key-Flags: resolution="31x13", keys="4"
Accept: application/sdp
Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE
Allow-Events: talk, hold, refer, call-info
Supported: timer, 100rel, replaces, from-change
Session-Expires: 3600
Min-SE: 90
Proxy-Authorization: Digest username="301",realm="teste.demo.pt",nonce="VZ45hFWeOFh4j60H/FTV12CfMIHUwH3/",uri="sip:3022@teste.demo.pt;user=phone",response="c1d749e844a81cc68841c1d43be87885",algorithm=MD5 Content-Type: application/sdp
Content-Length: 407
P-Voicis-LB: 10.0.20.103
P-Voicis-LBPort: 5062
P-VOICIS-Src-Ip: 100.64.250.254
P-VOICIS-Src-Port: 5060
P-VOICIS-Src-Proto: udp
P-Auth-Info: 1
P-VOICIS-Src-Nat: 1
v=0
o=root 1097951374 1097951374 IN IP4 192.168.30.107
s=call
c=IN IP4 192.168.30.107
t=0 0
m=audio 19818 RTP/AVP 9 0 8 3 99 112 18 101
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:99 G726-32/8000
a=rtpmap:112 AAL2-G726-32/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=sendrecv
9(9082) DEBUG: pv [pv_core.c:376]: pv_get_xto_attr(): no Tag parameter
9(9082) DEBUG: dialog [dlg_hash.c:614]: dlg_lookup(): ref dlg 0x7fe1fd3d6ed8 with 1 -> 2
9(9082) DEBUG: dialog [dlg_hash.c:616]: dlg_lookup(): dialog id=2457 found on entry 2631
9(9082) DEBUG: dialog [dlg_hash.c:832]: dlg_unref(): unref dlg 0x7fe1fd3d6ed8 with 1 -> 1
9(9082) DEBUG: dialog [dlg_hash.c:614]: dlg_lookup(): ref dlg 0x7fe1fd3d6ed8 with 1 -> 2
9(9082) DEBUG: dialog [dlg_hash.c:616]: dlg_lookup(): dialog id=2457 found on entry 2631
9(9082) DEBUG: dialog [dlg_hash.c:832]: dlg_unref(): unref dlg 0x7fe1fd3d6ed8 with 1 -> 1
9(9082) DEBUG: <core> [select.c:412]: run_select(): Calling SELECT 0x7fe216f4e380
9(9082) DEBUG: dialog [dlg_hash.c:614]: dlg_lookup(): ref dlg 0x7fe1fd3d6ed8 with 1 -> 2
9(9082) DEBUG: dialog [dlg_hash.c:616]: dlg_lookup(): dialog id=2457 found on entry 2631
9(9082) DEBUG: dialog [dlg_hash.c:832]: dlg_unref(): unref dlg 0x7fe1fd3d6ed8 with 1 -> 1
9(9082) DEBUG: auth_db [auth_db_mod.c:263]: w_is_subscriber(): uri [sip:301@teste.demo.pt] table [subscriber] flags [1] 9(9082) DEBUG: <core> [db_res.c:116]: db_new_result(): allocate 56 bytes for result set at 0x7fe2174742e0
9(9082) DEBUG: db_mysql [km_res.c:66]: db_mysql_get_columns(): 2 columns returned from the query
9(9082) DEBUG: <core> [db_res.c:154]: db_allocate_columns(): allocate 16 bytes for result names at 0x7fe217474678
9(9082) DEBUG: <core> [db_res.c:165]: db_allocate_columns(): allocate 8 bytes for result types at 0x7fe216d82c08
9(9082) DEBUG: db_mysql [km_res.c:84]: db_mysql_get_columns(): allocate 16 bytes for RES_NAMES[0] at 0x7fe217474630
9(9082) DEBUG: db_mysql [km_res.c:91]: db_mysql_get_columns(): RES_NAMES(0x7fe217474630)[0]=[domain]
9(9082) DEBUG: db_mysql [km_res.c:135]: db_mysql_get_columns(): use DB1_STRING result type
9(9082) DEBUG: db_mysql [km_res.c:84]: db_mysql_get_columns(): allocate 16 bytes for RES_NAMES[1] at 0x7fe2174745e8
9(9082) DEBUG: db_mysql [km_res.c:91]: db_mysql_get_columns(): RES_NAMES(0x7fe2174745e8)[1]=[rpid]
9(9082) DEBUG: db_mysql [km_res.c:99]: db_mysql_get_columns(): use DB1_INT result type
9(9082) DEBUG: <core> [db_res.c:184]: db_allocate_rows(): allocate 16 bytes for rows at 0x7fe2174745a0
9(9082) DEBUG: <core> [db_row.c:117]: db_allocate_row(): allocate 64 bytes for row values at 0x7fe217469af0
9(9082) DEBUG: <core> [db_val.c:115]: db_str2val(): converting STRING [teste.demo.pt] 9(9082) DEBUG: <core> [db_val.c:71]: db_str2val(): converting INT [10]
9(9082) DEBUG: <core> [db_res.c:79]: db_free_columns(): freeing 2 columns
9(9082) DEBUG: <core> [db_res.c:83]: db_free_columns(): freeing RES_NAMES[0] at 0x7fe217474630
9(9082) DEBUG: <core> [db_res.c:83]: db_free_columns(): freeing RES_NAMES[1] at 0x7fe2174745e8
9(9082) DEBUG: <core> [db_res.c:92]: db_free_columns(): freeing result names at 0x7fe217474678
9(9082) DEBUG: <core> [db_res.c:97]: db_free_columns(): freeing result types at 0x7fe216d82c08
9(9082) DEBUG: <core> [db_res.c:52]: db_free_rows(): freeing 1 rows
9(9082) DEBUG: <core> [db_row.c:95]: db_free_row(): freeing row values at 0x7fe217469af0
9(9082) DEBUG: <core> [db_res.c:60]: db_free_rows(): freeing rows at 0x7fe2174745a0
9(9082) DEBUG: <core> [db_res.c:134]: db_free_result(): freeing result set at 0x7fe2174742e0
9(9082) DEBUG: uac [uac.c:441]: w_replace_from(): dsp=0x7fff3aad9690 (len=3) , uri=0x7fff3aad96a0 (len=29)
9(9082) DEBUG: uac [replace.c:291]: replace_uri(): removing display ["301"]
9(9082) DEBUG: uac [replace.c:443]: replace_uri(): encode is=<VnRhajNkWUhoNHZhY2tNaHFnOWhWdGFqM2RZSGg-> len=40
9(9082) DEBUG: siputils [checks.c:97]: has_totag(): no totag
9(9082) DEBUG: rtpengine [rtpengine_funcs.c:140]: check_content_type(): type <application/sdp> found valid
9(9082) DEBUG: rtpengine [rtpengine.c:1527]: rtpp_function_call(): proxy reply: d3:sdp417:v=0
o=root 1097951374 1097951374 IN IP4 100.64.250.4
s=call
c=IN IP4 100.64.250.4
t=0 0
m=audio 41660 RTP/AVP 9 0 8 3 99 112 18 101
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:99 G726-32/8000
a=rtpmap:112 AAL2-G726-32/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=sendrecv
a=rtcp:41661
6:result2:oke
9(9082) DEBUG: <core> [msg_translator.c:422]: clen_builder(): content-length: 417 (417)
9(9082) DEBUG: <core> [msg_translator.c:158]: check_via_address(): (10.0.20.103, 10.0.20.103, 0)
9(9082) DEBUG: tm [t_hooks.c:266]: run_trans_callbacks_internal(): DBG: trans=0x7fe1fd3e5c68, callback type 4194304, id 0 entered
9(9082) DEBUG: siptrace [siptrace.c:1865]: pipport2su(): the port string is 5060
9(9082) DEBUG: siptrace [siptrace.c:1865]: pipport2su(): the port string is 5062
9(9082) DEBUG: <core> [proxy.c:265]: mk_proxy(): doing DNS lookup...
9(9082) DEBUG: siptrace [siptrace.c:1677]: trace_send_hep_duplicate(): setting up the socket_info
9(9082) DEBUG: tm [t_funcs.c:362]: t_relay_to(): SER: new transaction fwd'ed
9(9082) DEBUG: dialog [dlg_hash.c:614]: dlg_lookup(): ref dlg 0x7fe1fd3d6ed8 with 1 -> 2
9(9082) DEBUG: dialog [dlg_hash.c:616]: dlg_lookup(): dialog id=2457 found on entry 2631
9(9082) DEBUG: dialog [dlg_hash.c:832]: dlg_unref(): unref dlg 0x7fe1fd3d6ed8 with 1 -> 1