Esempio n. 1
0
bool BlabbleCall::SendDTMF(const std::string& dtmf)
{
	BlabbleAccountPtr p;
	char c;
	pj_str_t digits;
	pj_status_t status;

	if (dtmf.length() != 1)
	{
		throw FB::script_error("SendDTMF may only send one character!");
	}
	
	c = dtmf[0];
	if (c != '#' && c != '*' && c < '0' && c > '9')
	{
		throw FB::script_error("SendDTMF may only send numbers, # and *");
	}

	if (!(p = CheckAndGetParent()))
		return false;

	digits.ptr = &c;
	digits.slen = 1;
	status = pjsua_call_dial_dtmf(call_id_, &digits);

	return status == PJ_SUCCESS;
}
Esempio n. 2
0
static void ui_send_dtmf_2833()
{
    if (current_call == -1) {
	PJ_LOG(3,(THIS_FILE, "No current call"));
    } else if (!pjsua_call_has_media(current_call)) {
	PJ_LOG(3,(THIS_FILE, "Media is not established yet!"));
    } else {
	pj_str_t digits;
	int call = current_call;
	pj_status_t status;
	char buf[128];

	if (!simple_input("DTMF strings to send (0-9*R#A-B)", buf,
	    sizeof(buf)))
	{
	    return;
	}

	if (call != current_call) {
	    puts("Call has been disconnected");
	    return;
	}

	digits = pj_str(buf);
	status = pjsua_call_dial_dtmf(current_call, &digits);
	if (status != PJ_SUCCESS) {
	    pjsua_perror(THIS_FILE, "Unable to send DTMF", status);
	} else {
	    puts("DTMF digits enqueued for transmission");
	}
    }
}
Esempio n. 3
0
void ScreenPhone::sendDTMF(pjsua_call_id call_id, const char* digits)
{
    const char* p_digits;

    p_digits = digits;

    pj_str_t pj_digits = pj_str((char*)p_digits);
    pjsua_call_info call_info;

    //qDebug() << "Trying to play dtmf " << digits;

    if(call_id>=0)
    {
        pjsua_call_get_info(call_id, &call_info);
        if (call_info.media_status == PJSUA_CALL_MEDIA_ACTIVE)
        {
            playDTMF(call_id, (char*)p_digits);
            pjsua_call_dial_dtmf(call_id, &pj_digits);
            return;
        }
    }
    else
    {
        playDTMF(call_id, (char*)p_digits);
    }
}
Esempio n. 4
0
void QVDoorcom::onHangupPressed() {
    popup->hide();
    if (active_call < 0) {
        return;
    }

    pjsua_call_info ci;
    if (!pjsua_call_get_info(active_call, &ci) == PJ_SUCCESS) {
        return;
    }
    pjsua_conf_disconnect(bell_port_id,0);
    qDebug() << pj2qstring( ci.state_text);
    if ((ci.state == PJSIP_INV_STATE_INCOMING) || (ci.state == PJSIP_INV_STATE_EARLY)) {
        pjsua_call_answer(active_call,486,NULL,NULL); /* Reject with busy */
        active_call = -1;
    } else if (ci.state == PJSIP_INV_STATE_CONNECTING) {
        pjsua_call_hangup(active_call,200,NULL,NULL); /* Hangup */
        active_call = -1;
    } else {
        if (!code_hangup.isEmpty()) {
#ifdef USE_INBAND
            pjmedia_tone_digit d[16];
            unsigned i, count = code_hangup.length();

            if (count > PJ_ARRAY_SIZE(d)) {
                count = PJ_ARRAY_SIZE(d);
            }

            pj_bzero(d, sizeof(d));
            int n=0;
            for (i=0; i<count; i++) {
                char code = code_hangup.at(i).toLatin1();
                qDebug() << "i" << i << code << "n" << n;
                if (((code < '0') || (code > '9')) && (code != '*') && (code != '#')) {
                    continue;
                }
                d[n].digit = code;
                d[n].on_msec = 200;
                d[n].off_msec = 200;
                d[n].volume = 0;
                n++;
            }
            pjmedia_tonegen_play_digits(pj_tonegen, n, d, 0);
#else
            pj_str_t code = pj_str(strdup(code_hangup.toUtf8().data()));
            pjsua_call_dial_dtmf(active_call,&code);
#endif
            hangup_timer.setInterval(400*code_hangup.length());
        } else {
            hangup_timer.setInterval(100);
        }
        qDebug() << "hangup timer started";
        hangup_timer.start();
    }
}
Esempio n. 5
0
void QVDoorcom::onDoorOpenPressed() {
    if (active_call < 0) {
        return;
    }

    pjsua_call_info ci;
    if (!pjsua_call_get_info(active_call, &ci) == PJ_SUCCESS) {
        return;
    }
    if (ci.state != PJSIP_INV_STATE_CONFIRMED) {
        return;
    }
    popup->hide();
    if (!code_dooropen.isEmpty()) {
#ifdef USE_INBAND
        pjmedia_tone_digit d[16];
        unsigned i, count = code_dooropen.length();

        if (count > PJ_ARRAY_SIZE(d)) {
            count = PJ_ARRAY_SIZE(d);
        }

        pj_bzero(d, sizeof(d));
        int n=0;
        for (i=0; i<count; i++) {
            char code = code_dooropen.at(i).toLatin1();
            qDebug() << "i" << i << code << "n" << n;
            if (((code < '0') || (code > '9')) && (code != '*') && (code != '#')) {
                continue;
            }
            d[n].digit = code;
            d[n].on_msec = 200;
            d[n].off_msec = 200;
            d[n].volume = 0;
            n++;
        }
        pjmedia_tonegen_play_digits(pj_tonegen, n, d, 0);
#else
        pj_str_t code = pj_str(strdup(code_dooropen.toUtf8().data()));
        pjsua_call_dial_dtmf(active_call,&code);
#endif
        hangup_timer.setInterval(400*code_dooropen.length());
    } else {
        hangup_timer.setInterval(100);
    }
    qDebug() << "hangup timer started";
    hangup_timer.start();
}
Esempio n. 6
0
void QVDoorcom::onDTMFTimer() {
    qDebug() << "DTMF timer";
    pj_str_t code = pj_str(strdup(code_accept.toUtf8().data()));
    pjsua_call_dial_dtmf(active_call,&code);
}