Uploaded image for project: 'FreeSWITCH'
  1. FreeSWITCH
  2. FS-7578

Telephone-event codec clock-rate mismatch (leads to DTMF issue)

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.18, 1.4.19, 1.4.20
    • Fix Version/s: 1.6
    • Component/s: freeswitch-core
    • Security Level: public
    • Labels:
      None
    • Environment:
      Linux
    • CPU Architecture:
      x86-64
    • Kernel:
      Linux
    • Userland:
      GNU/Linux
    • Distribution:
      CentOS
    • Distribution Version:
      CentOS Based (3.x kernel)
    • Compiler:
      gcc
    • FreeSWITCH GIT Revision:
      9eb887af478eb7615cfbb1f43055e5c1b73ee9ef
    • GIT Master Revision hash::
      9eb887af478eb7615cfbb1f43055e5c1b73ee9ef

      Description

      Telephone-event codec is used to send/receive DTMF.

      Telephone-event codec clock rate should be the clock rate of the audio codec.

      But when FS receives SDP as follows:

      m=audio 7090 RTP/AVP 96 97 98 99 100 102 103 0 8 104 101 105 106 107 108
      [...]
      a=rtpmap:101 telephone-event/48000
      a=rtpmap:105 telephone-event/16000
      a=rtpmap:106 telephone-event/24000
      a=rtpmap:107 telephone-event/12000
      a=rtpmap:108 telephone-event/8000

      FS replies as follows:
      a=rtpmap:101 telephone-event/8000

      The remote client will see that FS is changing the clock-rate of the 101 payload from 48000 to 8000 .

      RFC4733 states ( https://tools.ietf.org/html/rfc4733#section-2.1 ) :

      "Named telephone events are carried as part of the audio stream and
      MUST use the same sequence number and timestamp base as the regular
      audio channel to simplify the generation of audio waveforms at a
      gateway"

      For example, for Opus, the RTP clock rate is at 48000 , but the telephone-event clock rate offered by FS is 8000, so DTMF on RFC compliant clients would not work (sending telephone-event/8000 over a 48000 Hz audio stream is prohibited).

      This situation is becoming more common, as Opus is becoming used more and more.

      This patch addresses the issue,replacing the hardcoded clock rate (8000) with the clock rate of the offered audio codec..
      Pull request here :
      https://freeswitch.org/stash/projects/FS/repos/freeswitch/pull-requests/258/overview

      Tested with <param name="inbound-codec-negotiation" value="greedy"/>

        Activity

        dragos_oancea Dragos Oancea created issue -
        Hide
        brian Brian West added a comment -
        What does this do if you have 8k,16k,32k and 48k codecs in the offer?
        Show
        brian Brian West added a comment - What does this do if you have 8k,16k,32k and 48k codecs in the offer?
        Hide
        dragos_oancea Dragos Oancea added a comment -
        The change impacts only replies generated by FS.
        Now FS will always reply with telephone-event/8000 , but with the change it will reply with the clock rate of the chosen audio codec, and the remote client will send DTMF.
        So if for example FS answers with SILK/16000, telephone event clock rate will be 16000 , if FS answers with OPUS/48000 , telephone-event clock rate will be 48000.

        Example:
        incoming INVITE SDP:

        m=audio 30298 RTP/AVP 96 97 98 99 100 102 0 8 101 103 104 105 106
        a=rtpmap:96 opus/48000/2
        a=fmtp:96 useinbandfec=1; stereo=0; sprop-stereo=0
        a=rtpmap:97 SILK/16000
        a=rtpmap:98 SILK/24000
        a=rtpmap:99 SILK/8000
        a=rtpmap:100 SILK/12000
        a=rtpmap:102 iLBC/8000
        a=fmtp:102 mode=30
        a=rtpmap:101 telephone-event/48000
        a=rtpmap:103 telephone-event/16000
        a=rtpmap:104 telephone-event/24000
        a=rtpmap:105 telephone-event/12000
        a=rtpmap:106 telephone-event/8000
        a=rtcp:30299

        reply SDP (before patch ):
        2015-05-26 14:20:04.821039 [DEBUG] mod_sofia.c:780 Local SDP sofia/internal/99973251@voip.sipdomain.com:
        v=0
        o=FreeSWITCH 1432623041 1432623043 IN IP4 10.10.10.144
        s=FreeSWITCH
        c=IN IP4 10.10.10.144
        t=0 0
        m=audio 26956 RTP/AVP 96 101
        a=rtpmap:96 opus/48000/2
        a=fmtp:96 useinbandfec=1; maxaveragebitrate=12000; maxplaybackrate=8000
        a=rtpmap:101 telephone-event/8000 <- the client will not send DTMF over this RTP stream
        a=fmtp:101 0-16
        a=ptime:20
        a=sendrecv
        a=rtcp:26957 IN IP4 10.10.10.144

        reply SDP ( after patch ):
        2015-05-26 14:20:04.821039 [DEBUG] mod_sofia.c:780 Local SDP sofia/internal/99973251@voip.sipdomain.com:
        v=0
        o=FreeSWITCH 1432623041 1432623043 IN IP4 10.10.10.144
        s=FreeSWITCH
        c=IN IP4 10.10.10.144
        t=0 0
        m=audio 26956 RTP/AVP 96 101
        a=rtpmap:96 opus/48000/2
        a=fmtp:96 useinbandfec=1; maxaveragebitrate=12000; maxplaybackrate=8000
        a=rtpmap:101 telephone-event/48000 <- the clock rate of the telephone-event codec
        a=fmtp:101 0-16
        a=ptime:20
        a=sendrecv
        a=rtcp:26957 IN IP4 10.10.10.144

        Show
        dragos_oancea Dragos Oancea added a comment - The change impacts only replies generated by FS. Now FS will always reply with telephone-event/8000 , but with the change it will reply with the clock rate of the chosen audio codec, and the remote client will send DTMF. So if for example FS answers with SILK/16000, telephone event clock rate will be 16000 , if FS answers with OPUS/48000 , telephone-event clock rate will be 48000. Example: incoming INVITE SDP: m=audio 30298 RTP/AVP 96 97 98 99 100 102 0 8 101 103 104 105 106 a=rtpmap:96 opus/48000/2 a=fmtp:96 useinbandfec=1; stereo=0; sprop-stereo=0 a=rtpmap:97 SILK/16000 a=rtpmap:98 SILK/24000 a=rtpmap:99 SILK/8000 a=rtpmap:100 SILK/12000 a=rtpmap:102 iLBC/8000 a=fmtp:102 mode=30 a=rtpmap:101 telephone-event/48000 a=rtpmap:103 telephone-event/16000 a=rtpmap:104 telephone-event/24000 a=rtpmap:105 telephone-event/12000 a=rtpmap:106 telephone-event/8000 a=rtcp:30299 reply SDP (before patch ): 2015-05-26 14:20:04.821039 [DEBUG] mod_sofia.c:780 Local SDP sofia/internal/99973251@voip.sipdomain.com: v=0 o=FreeSWITCH 1432623041 1432623043 IN IP4 10.10.10.144 s=FreeSWITCH c=IN IP4 10.10.10.144 t=0 0 m=audio 26956 RTP/AVP 96 101 a=rtpmap:96 opus/48000/2 a=fmtp:96 useinbandfec=1; maxaveragebitrate=12000; maxplaybackrate=8000 a=rtpmap:101 telephone-event/8000 <- the client will not send DTMF over this RTP stream a=fmtp:101 0-16 a=ptime:20 a=sendrecv a=rtcp:26957 IN IP4 10.10.10.144 reply SDP ( after patch ): 2015-05-26 14:20:04.821039 [DEBUG] mod_sofia.c:780 Local SDP sofia/internal/99973251@voip.sipdomain.com: v=0 o=FreeSWITCH 1432623041 1432623043 IN IP4 10.10.10.144 s=FreeSWITCH c=IN IP4 10.10.10.144 t=0 0 m=audio 26956 RTP/AVP 96 101 a=rtpmap:96 opus/48000/2 a=fmtp:96 useinbandfec=1; maxaveragebitrate=12000; maxplaybackrate=8000 a=rtpmap:101 telephone-event/48000 <- the clock rate of the telephone-event codec a=fmtp:101 0-16 a=ptime:20 a=sendrecv a=rtcp:26957 IN IP4 10.10.10.144
        brian Brian West made changes -
        Field Original Value New Value
        Status New [ 1 ] Needs Review [ 10002 ]
        mikej Mike Jerris made changes -
        Status Needs Review [ 10002 ] Resolved [ 5 ]
        Fix Version/s 1.6 [ 11215 ]
        Resolution Fixed [ 1 ]
        Hide
        danielsokolowski Daniel Sokolowski added a comment - - edited
        This bug is linked from a Linphone bug thread here: https://lists.gnu.org/archive/html/linphone-users/2015-05/msg00084.html .

        I am posting a workarround here for the benefit of others which is to change Linphone's preferences to use 8000Hz codecs, see http://danielsokolowski.blogspot.ca/2015/10/linphone-keys-dtmf-not-working-with.html
        Show
        danielsokolowski Daniel Sokolowski added a comment - - edited This bug is linked from a Linphone bug thread here: https://lists.gnu.org/archive/html/linphone-users/2015-05/msg00084.html . I am posting a workarround here for the benefit of others which is to change Linphone's preferences to use 8000Hz codecs, see http://danielsokolowski.blogspot.ca/2015/10/linphone-keys-dtmf-not-working-with.html
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        New New Needs Review Needs Review
        5d 22h 24m 1 Brian West 01/Jun/15 9:55 AM
        Needs Review Needs Review Resolved Resolved
        32d 8h 37m 1 Mike Jerris 03/Jul/15 6:32 PM

          People

          • Assignee:
            anthm Anthony Minessale II
            Reporter:
            dragos_oancea Dragos Oancea
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development