Exemple #1
0
bool BoardFXO::KhompPvtFXO::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    callFXO()->_flags.clear(Kflags::CALL_WAIT_SEIZE);
    callFXO()->_flags.clear(Kflags::WAIT_SEND_DTMF);

    /* if received some disconnect from 'drop collect call'
       feature of some pbx, then leave the call rock and rolling */
    //Board::board(_target.device)->_timers.del(callFXO()->_idx_disconnect);

    bool fax_detected = callFXO()->_flags.check(Kflags::FAX_DETECTED) || (callFXO()->_var_fax_adjust == T_TRUE);

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN || fax_detected ?
        Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() && !fax_detected : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN || fax_detected ?
        Opt::_options._echo_canceller() && !fax_detected : (call()->_var_echo_state == T_TRUE));

    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN || fax_detected ?
        Opt::_options._auto_gain_control() && !fax_detected : (call()->_var_gain_state == T_TRUE));

    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(FXO) Audio callbacks initialized successfully"));
    }

    return KhompPvt::setupConnection();
}
Exemple #2
0
bool BoardGSM::KhompPvtGSM::setupConnection()
{
    if(!call()->_flags.check(Kflags::IS_INCOMING) && !call()->_flags.check(Kflags::IS_OUTGOING))
    {
        DBG(FUNC,PVT_FMT(_target, "Channel already disconnected"));
        return false;
    }

    bool res_out_of_band_dtmf = (call()->_var_dtmf_state == T_UNKNOWN ?
                                 Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() : (call()->_var_dtmf_state == T_TRUE));

    bool res_echo_cancellator = (call()->_var_echo_state == T_UNKNOWN ?
                                 Opt::_options._echo_canceller() : (call()->_var_echo_state == T_TRUE));


    bool res_auto_gain_cntrol = (call()->_var_gain_state == T_UNKNOWN ?
                                 Opt::_options._auto_gain_control() : (call()->_var_gain_state == T_TRUE));


    if (!call()->_flags.check(Kflags::REALLY_CONNECTED))
    {
        obtainRX(res_out_of_band_dtmf);

        /* esvazia buffers de leitura/escrita */
        cleanupBuffers();

        if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
            dtmfSuppression(res_out_of_band_dtmf);

        if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
            echoCancellation(res_echo_cancellator);

        if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
            autoGainControl(res_auto_gain_cntrol);

        startListen(false);

        startStream();

        DBG(FUNC, PVT_FMT(_target, "(GSM) Audio callbacks initialized successfully"));
    }

    return Board::KhompPvt::setupConnection();
}
Exemple #3
0
bool BoardFXO::KhompPvtFXO::onDtmfSendFinish(K3L_EVENT *e)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        ret = KhompPvt::onDtmfSendFinish(e);

        if (callFXO()->_flags.check(Kflags::EARLY_RINGBACK))
        {
            callFXO()->_flags.clear(Kflags::EARLY_RINGBACK);

            /* start grabbing */
            startListen();

            /* activate resources early... */
            bool fax_detected = callFXO()->_flags.check(Kflags::FAX_DETECTED);

            bool res_out_of_band_dtmf = Opt::_options._suppression_delay() && Opt::_options._out_of_band_dtmfs() && !fax_detected;
            bool res_echo_cancellator = Opt::_options._echo_canceller() && !fax_detected;
            bool res_auto_gain_cntrol = Opt::_options._auto_gain_control() && !fax_detected;

            if (!call()->_flags.check(Kflags::KEEP_DTMF_SUPPRESSION))
                dtmfSuppression(res_out_of_band_dtmf);

            if (!call()->_flags.check(Kflags::KEEP_ECHO_CANCELLATION))
                echoCancellation(res_echo_cancellator);

            if (!call()->_flags.check(Kflags::KEEP_AUTO_GAIN_CONTROL))
                autoGainControl(res_auto_gain_cntrol);

            /* start sending audio if wanted so */
            if (Opt::_options._fxo_send_pre_audio())
                startStream();

            //TODO: Verificar isso aqui
            if (call()->_pre_answer)
            {
                /* tell the user we are answered! */
                switch_channel_mark_answered(getFSChannel());
                //pvt->signal_state(AST_CONTROL_ANSWER);
            }
            else
            {
                /* are we ringing, now? lets try this way! */
                switch_channel_mark_ring_ready(getFSChannel());
                //pvt->signal_state(AST_CONTROL_RINGING);
            }
        }
    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }
    catch(Board::KhompPvt::InvalidSwitchChannel & err)
    {
        LOG(ERROR, PVT_FMT(_target, "(FXO) r (no valid channel: %s)") % err._msg.c_str());
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}