I've been working on a configuration to solve the same problem. In my case it's a simple in-and-out bridging configuration on a single sofia profile, where the a-leg can be inband or RFC2833 an any number of codecs, but the b-leg must be inband on G.711u. I have the profile configured with dtmf-mode=rfc2833 as a default. Then, in the dialplan:
<extension name="detect-2833" continue="true">
<condition field="${switch_r_sdp}" expression="a=rtpmap:\d+ telephone-event\/\d+">
<action application="set" data="ringback=${us-ring}"/>
<action application="start_dtmf_generate"/>
<action application="export" data="nolocal:execute_on_answer=start_dtmf"/>
<anti-action application="set" data="dtmf_type=none"/>
<extension name="sendit">
<condition field="destination_number" expression="(.*)">
<action application="bridge" data="{dtmf_type=none}sofia/public/$1@${host2}"/>
The first extension seems to do a decent job at detecting whether or not RFC2833-style DTMF is present in the SDP ("telephone-event"), and if so:
- start_dtmf_generate: This will cause b-leg inband tones when DTMF is detected on the a-leg. This solves the 2833-to-inband (a to b) direction.
- export nolocal:execute_on_answer=start_dtmf: This enables DSP detection of inband tones on the b-leg, causing them to relay back to the a-leg as RFC2833 events.
- set ringback: Turning on this DTMF stuff causes the a-leg to see a 183 Session Progress, probably due to the media processing. Without setting the ringback, a 180 Ringing from the b-leg doesn't indicate at all on the a-leg. With setting, it's effectively converted into a 183 Session Progress with inband ringback.
If the a-leg does not have RFC2833 indicated, I assume it's inband because I don't support DTMF over SIP INFO. In this case the detect-2833 extension's anti-action sets the dtmf-mode appropriately, overriding the 2833 default in the profile. This causes the inband tones to pass straight through FS without any detection or manipulation, which is just fine for my case.
The good news is this configuration seems to do everything I've described. The bad news is that it does not mute the inband tones as they travel from b-leg to a-leg. I haven't figured out that piece yet. Suggestions welcome!
- Jeff