KeyPad Tone Question

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

 



Hello to all of you, i have follow this website to program a keypad tone.

http://trac.pjsip.org/repos/wiki/FAQ#inband-dtmf but i cannot get the
desired result when i clicked the dial pad.

I just want to create a code that when user clicked one it play a sound and
send the command to callee.

And if user clicked two, it play difference sound and send the command to
callee too.

I just want to play sound for each digit clicked rather many digits clicked
in the website.

I really tried out my best.

This is my code so far.

[code]
DTMFToneData* myTone;

struct DTMFToneData
{
public:
  DTMFToneData();
  ~DTMFToneData();

  void InitToneDesc();

  pj_pool_t* myPool;
  pjmedia_port* tonegenPort;
  pjsua_conf_port_id toneSlot;

  pjmedia_tone_desc* keyTone;

};

DTMFToneData::DTMFToneData()
  : myPool(&pj_pool_t() ),
  tonegenPort(&pjmedia_port() ),
  toneSlot(pjsua_conf_port_id() ),
  keyTone(new pjmedia_tone_desc [3] )
{
 InitToneDesc();

}
// =============================================
DTMFToneData::~DTMFToneData()
{
 delete keyTone;
}
// =============================================
void DTMFToneData::InitToneDesc()
{
 for (int loop = 0; loop < 3; ++loop)
 {
  keyTone[loop].freq1 = 100;
  keyTone[loop].freq2 = 200;
  keyTone[loop].on_msec = 100;
  keyTone[loop].off_msec = 200;
  keyTone[loop].volume = 3;
 }

}

void VOIP::createDTMFTone()
{
 createToneGenerator();
 RegisterToneGenerator();
 ConnectToneGenerator();

}
// ============================================
void VOIP::DestroyDTMFTone()
{
 pjsua_conf_remove_port(myTone->toneSlot);
 pjmedia_port_destroy(myTone->tonegenPort);
 pj_pool_release(myTone->myPool);

}
// ============================================
void VOIP::createToneGenerator()
{
 myTone->myPool = pjsua_pool_create("DTMF Tone", 512, 512);
 myTone = PJ_POOL_ZALLOC_T(myTone->myPool,
   struct DTMFToneData);

 pjmedia_tonegen_create(myTone->myPool, 16000,
      1, 160, 16, 0, &myTone->tonegenPort );

 if (status != PJ_SUCCESS)
 {
  // PJ_LOG(4, () );
 }


}
// ============================================
void VOIP::RegisterToneGenerator()
{
 pjsua_conf_add_port(myTone->myPool,
  myTone->tonegenPort, &myTone->toneSlot);

 if (status != PJ_SUCCESS)
 {
  // PJ_LOG(4, () );
 }

}
// ============================================
void VOIP::ConnectToneGenerator()
{
 pjsua_conf_connect(myTone->toneSlot,
  callInfo.conf_slot);

 if (status != PJ_SUCCESS)
 {
  // PJ_LOG(4, () );
 }

}
// ============================================
void VOIP::PlayTone()
{
 pjmedia_tonegen_play(myTone->tonegenPort,
  3, myTone->keyTone, 0);
}


[/code]


Anything wrong with my code.

Please help.

Thanks.



-- 
Linux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20091017/9f1dd9be/attachment.html>


[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