inband DTMF tone generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

you can make it like this:

in init add create tone generator

ToneGenerator toneGenerator = new ToneGenerator();
toneGenerator.createToneGenerator(8000, 1);
ToneDigitVector digitVector = new ToneDigitVector();

add tone generator to audio port in onCallMediaStateCallback,
   if (toneGenerator != null) {
            toneGenerator.startTransmit(mEndpoint.audDevManager().getPlaybackDevMedia());
        }

and then use this method for dtmf

 public void PlayDTMFDigit(String digit) {
        if (!TextUtils.isEmpty(digit)) {
            try {
                ToneDigit toneDigit = new ToneDigit();
                toneDigit.setDigit(digit.charAt(0));
                toneDigit.setOn_msec((short) 100);
                toneDigit.setOff_msec((short) 200);
                if (toneGenerator.isBusy()) {
                    digitVector.add(toneDigit);
                } else {
                    digitVector.add(toneDigit);
                    toneGenerator.playDigits(digitVector);
                    digitVector.clear();
                }
            } catch (Exception e) {
                Log.e(this, "", e);
            }
        }
    }
Best Regards
Andrzej Grajnert



_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux