Пример #1
0
//----------------------------------------------------------------------
void SipPhone::muteMicrophoneForCall(const int &call_id, const float &mute)
{
    pjsua_call_info ci;
    
    pjsua_call_get_info(call_id,&ci);
    
    pjsua_conf_adjust_tx_level(ci.conf_slot, mute);
}
Пример #2
0
/**
 * \fn _ics_core_adjust_audio_volume()
 * \brief Tuy chinh am luong cho mic va speaker
 * \param agr1: ics_t *data
 * agr2: char *device
 * agr3: level
 */
static void _ics_core_adjust_audio_volume(ics_t *data, char *device, float level) {
	if (strcmp(device,"r") == 0) {
		pjsua_conf_adjust_rx_level(0, level);
	}
	else if (strcmp(device,"t") == 0) {
		pjsua_conf_adjust_tx_level(0, level);
	}
	else
		printf("Invalid input to adjust device");
}
Пример #3
0
Файл: ics.c Проект: mocidis/ics
/**
 * \fn _ics_adjust_audio_volume()
 * \brief Tuy chinh am luong cho mic va speaker
 * \param agr1: ics_t *data
 * agr2: char *device
 * agr3: level
 */
static void _ics_adjust_audio_volume(ics_t *data, int device, float level) {
    PJ_UNUSED_ARG(data);

    if (device == 0) {
        pjsua_conf_adjust_rx_level(0, level);
    }
    else if (device == 1) {
        pjsua_conf_adjust_tx_level(0, level);
    }
    else
        SHOW_LOG(3, "Invalid input to adjust device");
}
Пример #4
0
void ScreenPhone::setVolume(const float volume, const QString &device)
{
    if(device == "mic")
    {
        pjsua_conf_adjust_rx_level(0, volume);
        controller->qmlviewer->rootContext()->setContextProperty("micVolume", volume);
    }
    else if(device == "spk")
    {
        pjsua_conf_adjust_tx_level(0, volume);
        controller->qmlviewer->rootContext()->setContextProperty("spkVolume", volume);
    }
}
Пример #5
0
static void ui_adjust_volume()
{
    char buf[128];
    char text[128];
    sprintf(buf, "Adjust mic level: [%4.1fx] ", app_config.mic_level);
    if (simple_input(buf,text,sizeof(text))) {
	char *err;
	app_config.mic_level = (float)strtod(text, &err);
	pjsua_conf_adjust_rx_level(0, app_config.mic_level);
    }
    sprintf(buf, "Adjust speaker level: [%4.1fx] ", app_config.speaker_level);
    if (simple_input(buf,text,sizeof(text))) {
	char *err;
	app_config.speaker_level = (float)strtod(text, &err);
	pjsua_conf_adjust_tx_level(0, app_config.speaker_level);
    }
}
Пример #6
0
//----------------------------------------------------------------------
void SipPhone::muteSound(const bool &mute)
{
    float level = 0.f;
    if (mute)
    {
        LogInfo info(LogInfo::STATUS_MESSAGE, "phone", 0, "muteSound: true");
        signalLogData(info);
        level = 0.f;
    }
    else
    {
        LogInfo info(LogInfo::STATUS_MESSAGE, "phone", 0, "muteSound: false");
        signalLogData(info);
        level = 1.f;
    }
    speaker_level_ = level;
    pjsua_conf_adjust_tx_level(0, level);
    self_->signalSoundLevel(int(level * 255));
}
Пример #7
0
//=============================================================================
void SIPConference::AdjustTranVolume(pjsua_call_id call_id, float level)
{
	VFVW_LOG("entering AdjustTranVolume()");

	pjsua_call_info ci;
	pjsua_call_get_info (call_id, &ci);

	VFVW_LOG("AdjustTranVolume call_id=%d,level=%f", call_id, level);

#ifdef DEBUG
	unsigned tx_level = 0;
	unsigned rx_level = 0;
	status = pjsua_conf_get_signal_level(ci.conf_slot, &tx_level, &rx_level);
    if (status != PJ_SUCCESS) 
        error_exit ("Error get signal level", status);

	VFVW_LOG("current tx_level=%d,rx_level=%d", tx_level, rx_level);
#endif

	status = pjsua_conf_adjust_tx_level(ci.conf_slot, level);
    if (status != PJ_SUCCESS) 
        error_exit ("Error adjust tx level", status);
}
Пример #8
0
//----------------------------------------------------------------------
void SipPhone::init()
{
    pj_status_t status;
    /* Create pjsua first! */
    status = pjsua_create();

    if (status != PJ_SUCCESS)
    {
        LogInfo info(LogInfo::STATUS_FATAL_ERROR, "pjsip", status, "Error in pjsua_create()");
        signalLogData(info);
        return;
    }

    /* Init pjsua */
    {
        pjsua_config cfg;
        pjsua_logging_config log_cfg;
        ConfigFileHandler &config = ConfigFileHandler::getInstance();
        QString stun = config.getStunServer();
        pjsua_config_default(&cfg);

        if (stun.size())
        {
            char ch_stun[100];
            if (stun.size() > 99)
            {
                LogInfo info(LogInfo::STATUS_ERROR, "pjsip", 0, "Error init pjsip, stun-server too long");
                signalLogData(info);
                return;
            }

            strcpy(ch_stun, stun.toLocal8Bit().data());
            ch_stun[stun.size()] = 0;

            cfg.stun_srv[cfg.stun_srv_cnt++] = pj_str(ch_stun);
        }
        cfg.enable_unsolicited_mwi = PJ_FALSE;
        cfg.cb.on_incoming_call = &incomingCallCb;
        cfg.cb.on_call_state = &callStateCb;
        cfg.cb.on_call_media_state = &callMediaStateCb;
        cfg.cb.on_reg_state = &regStateCb;

        pjsua_logging_config_default(&log_cfg);
        log_cfg.console_level = 4;

        status = pjsua_init(&cfg, &log_cfg, NULL);
        printf("init successfull\n");
        if (status != PJ_SUCCESS)
        {
            LogInfo info(LogInfo::STATUS_FATAL_ERROR, "pjsip", status, "Error in pjsua_init()");
            signalLogData(info);
            return;
        }
    }

    /* Add UDP transport. */
    {
        pjsua_transport_config cfg;
        pjsua_acc_id aid;
        pjsua_transport_id transport_id = -1;
        pjsua_transport_config tcp_cfg;

        pjsua_transport_config_default(&cfg);
        cfg.port = 5060;

        status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, &transport_id);

        if (status != PJ_SUCCESS)
        {
            LogInfo info(LogInfo::STATUS_FATAL_ERROR, "pjsip", status, "Error creating transport");
            signalLogData(info);
            return;
        }

        /* Add local account */
        pjsua_acc_add_local(transport_id, PJ_TRUE, &aid);
        pjsua_acc_set_online_status(aid, PJ_TRUE);

        if (cfg.port == 0)
        {
            pjsua_transport_info ti;
            pj_sockaddr_in *a;

            pjsua_transport_get_info(transport_id, &ti);
            a = (pj_sockaddr_in*)&ti.local_addr;

            tcp_cfg.port = pj_ntohs(a->sin_port);
        }

    }
    /* Initialization is done, now start pjsua */
    status = pjsua_start();

    if (status != PJ_SUCCESS)
    {
        LogInfo info(LogInfo::STATUS_FATAL_ERROR, "pjsip", status, "Error starting PJSUA");
        signalLogData(info);
        return;
    }
    pjsua_conf_adjust_rx_level(0, 1.f);
    pjsua_conf_adjust_tx_level(0, 1.f);
    speaker_level_ = 1.f;
    mic_level_ = 1.f;
}