BOOL call_play_digit(pjsua_call_id call_id, const char *digits) { pjmedia_tone_digit d[16]; unsigned i, count = strlen(digits); struct my_call_data *cd; if (call_id !=-1 ) { cd = (struct my_call_data*) pjsua_call_get_user_data(call_id); } else { cd = tone_gen; } if (!cd) cd = call_init_tonegen(call_id); if (!cd) return FALSE; if (call_id == -1 ) { tone_gen = cd; } if (count > PJ_ARRAY_SIZE(d)) count = PJ_ARRAY_SIZE(d); pj_bzero(d, sizeof(d)); for (i=0; i<count; ++i) { d[i].digit = digits[i]; if (call_id !=-1 ) { d[i].on_msec = 260; d[i].off_msec = 200; } else { d[i].on_msec = 120; d[i].off_msec = 50; } d[i].volume = 0; } pjmedia_tonegen_play_digits(cd->tonegen, count, d, 0); if (call_id == -1 ) { if (destroyDTMFPlayerTimer) { KillTimer(NULL,destroyDTMFPlayerTimer); } destroyDTMFPlayerTimer = SetTimer(NULL,NULL,5000,(TIMERPROC)destroyDTMFPlayer); } return TRUE; }
void ScreenPhone::playDTMF(pjsua_call_id call_id, const char *digits) { pjmedia_tone_digit d[16]; unsigned i, count = strlen(digits); struct my_call_data *cd; if (call_id !=-1 ) { cd = (struct my_call_data*) pjsua_call_get_user_data(call_id); } else { cd = tone_gen; } if (!cd) cd = call_init_tonegen(call_id); if (call_id == -1 ) { tone_gen = cd; } if (count > PJ_ARRAY_SIZE(d)) count = PJ_ARRAY_SIZE(d); pj_bzero(d, sizeof(d)); for (i=0; i<count; ++i) { d[i].digit = digits[i]; if (call_id !=-1 ) { d[i].on_msec = 260; d[i].off_msec = 200; } else { d[i].on_msec = 120; d[i].off_msec = 50; } d[i].volume = 0; //qDebug() << "LOOP Playing DTMF " << digits; } pjmedia_tonegen_play_digits(cd->tonegen, count, d, 0); }