can't hear tone with pjmedia_tonegen_play_digits()

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

 



Hi guys,

I'm having a trouble playing the DTMF tone my  iPhone pjsip project. I
basically followed the same scheme from Siphon, and integrated the
following
methods to my application. All pjsip calls are returning PJ_SUCCESS,
everything seems to be working but I can't hear the tone. Is there
anything I'm missing?
Thanks!!


static struct my_call_data *call_init_tonegen(pjsua_call_id call_id) {
    pj_pool_t *pool;
    struct my_call_data *cd;
    pjsua_call_info ci;
    pj_status_t status;

    NSLog(@"generating tonegen.");

    pool = pjsua_pool_create("mycall", 512, 512);
    cd = PJ_POOL_ZALLOC_T(pool, struct my_call_data);
    cd->pool = pool;

    status = pjmedia_tonegen_create(cd->pool, 8000, 1, 160, 16, 0,
&cd->tonegen);

    if (status == PJ_SUCCESS) {
        NSLog(@"tonegen inited.");
        status = pjsua_conf_add_port(cd->pool, cd->tonegen, &cd->toneslot);
        if(status == PJ_SUCCESS){
            NSLog(@"pjsua_conf_add_port success.");
        } else {
            NSLog(@"pjsua_conf_add_port error.");
        }

        pjsua_call_get_info(call_id, &ci);
        status = pjsua_conf_connect(cd->toneslot, ci.conf_slot);
        if(status == PJ_SUCCESS)
            NSLog(@"toneslot conf connected.");
        else
            NSLog(@"toneslot conf connection error.");

        //	pjsua_conf_connect(cd->toneslot, 0); // sortie haut parleur.
        pjsua_call_set_user_data(call_id, (void*) cd);
    }
    else {
        pjsua_perror(THIS_FILE, "Error: Error creating DTMF generator", status);
        pj_pool_release(pool);
        cd = NULL;
    }

    return cd;
}

void sip_call_play_digit(pjsua_call_id call_id, char digit) {
    pjmedia_tone_digit d[1];
    struct my_call_data *cd;
    pj_status_t status;

    cd = (struct my_call_data*) pjsua_call_get_user_data(call_id);
    if (cd == NULL)
    {
        cd = call_init_tonegen(call_id);
        if (cd == NULL)
            return;
    }
    //else if (pjmedia_tonegen_is_busy(cd->tonegen))
    pjmedia_tonegen_stop(cd->tonegen);
    NSLog(@"creating tone digit.");
    d[0].digit = digit;
    d[0].on_msec = 100;
    d[0].off_msec = 100;
    d[0].volume = 32767;

    status = pjmedia_tonegen_play_digits(cd->tonegen, 1, d, 0);
    if(status == PJ_SUCCESS) {
        NSLog(@"pjmedia_tonegen_play_digits success");
    } else {
         NSLog(@"pjmedia_tonegen_play_digits error");
    }
}












--
V. Ogla Sungutay,
GUI Programmer
www.lyciasoft.com
gtalk: ogla at lyciasoft.com
g+: gplus.to/Proclus
skype: oglasungutay
twitter:?@proclus



[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