From 7a42c0c48c7366d7e60c675e9b4aaf2e75100b1c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 11 Nov 2020 13:15:45 -0500 Subject: [PATCH] TT#100251 distinguish between real transcoding and DTMF-related t/c Change-Id: I4643baeb87a7b71e8fc9d23c433fa958c9c11a71 --- daemon/codec.c | 23 +++++++++++++---------- t/auto-daemon-tests.pl | 7 ++----- utils/rtpengine-ng-client | 3 ++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 8ef703324..526e87de9 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -433,7 +433,7 @@ static struct rtp_payload_type *__check_dest_codecs(struct call_media *receiver, &pt->payload_type); if (!recv_pt || rtp_payload_type_cmp(pt, recv_pt)) { // can the sink receive supplemental codec but the receiver can't send it? - *sink_transcoding = 1; + *sink_transcoding |= 0x3; } } @@ -453,9 +453,14 @@ static void __check_send_codecs(struct call_media *receiver, struct call_media * struct rtp_payload_type *pt = l->data; struct rtp_payload_type *recv_pt = g_hash_table_lookup(receiver->codecs_send, &pt->payload_type); - if (!recv_pt || rtp_payload_type_cmp(pt, recv_pt) || (flags && flags->inject_dtmf)) { - // can the sink receive supplemental codec but the receiver can't send it? - *sink_transcoding = 1; + int tc_flag = 0; + if (!recv_pt || rtp_payload_type_cmp(pt, recv_pt)) + tc_flag |= 0x3; + if (flags && flags->inject_dtmf) + tc_flag |= 0x1; + if (tc_flag) { + // can the sink receive codec but the receiver can't send it? + *sink_transcoding |= tc_flag; continue; } @@ -466,10 +471,8 @@ static void __check_send_codecs(struct call_media *receiver, struct call_media * g_hash_table_lookup(sink->codec_handlers, GINT_TO_POINTER(recv_pt->payload_type)); if (!ch_recv) continue; - if (ch_recv->transcoder) { - *sink_transcoding = 1; - break; - } + if (ch_recv->transcoder) + *sink_transcoding |= 0x3; } } @@ -1000,7 +1003,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, // if we transcode, we transcode to the highest-preference supported codec // that the sink specified. determine this first. struct rtp_payload_type *pref_dest_codec = NULL; - int sink_transcoding = 0; + int sink_transcoding = 0; // 0x1 = any transcoder present, 0x2 = non pseudo transcoder present // keep track of supplemental payload types. we hash them by clock rate // in case there's several of them. the clock rates of the destination // codec and the supplemental codec must match. @@ -1042,7 +1045,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, MEDIA_CLEAR(sink, TRANSCODE); } - if (MEDIA_ISSET(sink, TRANSCODE)) + if (MEDIA_ISSET(sink, TRANSCODE) && (sink_transcoding & 0x2)) __accept_transcode_codecs(receiver, sink, flags); else __eliminate_rejected_codecs(receiver, sink, flags); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index e527adb64..90654a161 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -1579,10 +1579,9 @@ o=Z 58440449 0 IN IP4 89.225.243.254 s=Z c=IN IP4 203.0.113.1 t=0 0 -m=audio PORT RTP/AVP 8 0 9 101 +m=audio PORT RTP/AVP 8 0 101 a=rtpmap:8 PCMA/8000 a=rtpmap:0 PCMU/8000 -a=rtpmap:9 G722/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv @@ -3353,12 +3352,10 @@ o=- 1545997027 1 IN IP4 203.0.113.1 s=tester c=IN IP4 203.0.113.1 t=0 0 -m=audio PORT RTP/SAVP 0 8 9 101 +m=audio PORT RTP/SAVP 0 101 a=silenceSupp:off - - - - a=mptime:20 20 20 20 - a=rtpmap:0 PCMU/8000 -a=rtpmap:8 PCMA/8000 -a=rtpmap:9 G722/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv diff --git a/utils/rtpengine-ng-client b/utils/rtpengine-ng-client index d115ec789..be51376c4 100755 --- a/utils/rtpengine-ng-client +++ b/utils/rtpengine-ng-client @@ -76,6 +76,7 @@ GetOptions( 'OSRTP=s@' => \$options{'OSRTP'}, 'symmetric-codecs' => \$options{'symmetric codecs'}, 'asymmetric-codecs' => \$options{'asymmetric codecs'}, + 'inject-DTMF' => \$options{'inject DTMF'}, 'DTLS-fingerprint=s' => \$options{'DTLS-fingerprint'}, 'ICE-lite=s' => \$options{'ICE-lite'}, ) or die; @@ -90,7 +91,7 @@ for my $x (split(/,/, 'from-tag,to-tag,call-id,transport protocol,media address, for my $x (split(/,/, 'TOS,delete-delay')) { defined($options{$x}) and $packet{$x} = $options{$x}; } -for my $x (split(/,/, 'trust address,symmetric,asymmetric,unidirectional,force,strict source,media handover,sip source address,reset,port latching,no rtcp attribute,full rtcp attribute,loop protect,record call,always transcode,all,pad crypto,generate mid,fragment,original sendrecv,symmetric codecs,asymmetric codecs')) { +for my $x (split(/,/, 'trust address,symmetric,asymmetric,unidirectional,force,strict source,media handover,sip source address,reset,port latching,no rtcp attribute,full rtcp attribute,loop protect,record call,always transcode,all,pad crypto,generate mid,fragment,original sendrecv,symmetric codecs,asymmetric codecs,inject DTMF')) { defined($options{$x}) and push(@{$packet{flags}}, $x); } for my $x (split(/,/, 'origin,session connection')) {