void LPVMaterialSystem::update(Context& context, SceneContext& /*scene_context*/, RenderContext& render_context)
{
    ASSERT(is_handle_valid(gbuffer_.accumulator.id) && is_handle_valid(gbuffer_.normal.id) &&
           is_handle_valid(gbuffer_.depth.id), "Invalid GBuffer");
    // each pixel is a virtual point light
    Texture& texture = context.texture_pool.get(gbuffer_.accumulator.id);
    size_t vpl_number = texture.width() * texture.height();

    injection(render_context.draw_calls.add(), context, render_context, vpl_number);
    geometry_injection(render_context.draw_calls.add(), context, render_context, vpl_number);
    propagation(context, render_context);
}
Exemple #2
0
void RenderTarget::close()
{
    if (is_handle_valid(ds_.id))
        destroy_pool_object(context_->texture_pool, ds_.id);
    for (size_t i = 0, targets_number = desc_.color_targets; i < targets_number; ++i)
        destroy_pool_object(context_->texture_pool, rt_[i].id);
    impl_->close();
}
Exemple #3
0
	BOOL CLogDeviceConsole::Open(LPCTSTR param)
	{
		if (::AllocConsole())
		{
			m_free_console_on_close = true;
		}
		m_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
		if (is_handle_valid(m_handle))
		{
			CONSOLE_SCREEN_BUFFER_INFO csbi;
			GetConsoleScreenBufferInfo(m_handle, &csbi);
			m_default_attr = csbi.wAttributes;
			return TRUE;
		}
		return FALSE;
	}
Exemple #4
0
int32_t fs_opr_t::connect(uint32_t address, int32_t port, const char* pswd, bool reconnect) {
    int32_t ret = IMS_FAIL_CONNECT;
    char ip[sizeof "255.255.255.255"];

    if (reconnect) {
        disconnect();
        ims_tool_t::inet_ntop(address, ip, sizeof "255.255.255.255");

        if (esl_connect(&_handle, ip, _port, NULL, _pswd) == ESL_SUCCESS) {
            TRACE_LOG("reconnect to FreeSWITCH [%s:%d] success", ip, _port);
            eval(RECORD_BASEDIR, _recordbase, LEN_256);
            ret = IMS_SUCCESS;
        } else {
            WARNING_LOG("reconnect to FreeSWITCH [%s:%d] failed(%s)", ip, _port, _handle.err);
        }
    } else {
        if (is_handle_valid()) {
            return IMS_SUCCESS;
        }

        strncpy(_pswd, pswd, LEN_16);
        _address = address;
        _port = port;

        ims_tool_t::inet_ntop(address, ip, sizeof "255.255.255.255");

        if (esl_connect(&_handle, ip, _port, NULL, _pswd) == ESL_SUCCESS) {
            TRACE_LOG("connect to FreeSWITCH [%s:%d] success", ip, _port);
            eval(RECORD_BASEDIR, _recordbase, LEN_256);
            ret = IMS_SUCCESS;
        } else {
            WARNING_LOG("connect to FreeSWITCH [%s:%d] failed(%s)", ip, _port, _handle.err);
        }
    }

    return ret;
}
Exemple #5
0
int32_t fs_opr_t::get_event(fs_event_t& event, uint32_t timeout) {
    FUNC_BEGIN();
    bzero(&event, sizeof(event));
    (void)fs_resp;

    //if(esl_recv_timed(&_handle,timeout*1000)==ESL_SUCCESS){
    //check_q If set to 1, will check the handle queue (handle->race_event) and return the last
    //event from it
    //
    //没太看明白 稍微看了下源码,好像是set为1则取队列中的。不设置为1则可能丢事件,需要再次确定
    //if(esl_recv_event_timed(&_handle, timeout, 1, NULL)==ESL_SUCCESS){
    //使用带超时的接口会导致获取的fsevent事件内容为空,具体原因未知
    if (esl_recv_event_timed(&_handle, 0, 1, NULL) == ESL_SUCCESS) {
        event.timestamp = 0;
        //拷贝事件到event中
        get_head_val("Event-Name", event.name, LEN_64);

        if (IMS_SUCCESS == get_head_val("Event-Date-Timestamp", szcmd, LEN_512)) {
            event.timestamp = atoll(szcmd);
        } else {
            WARNING_LOG("get head_val Event-Date-Timestamp failed.!");
        }

        if (strcasecmp(event.name, "HEARTBEAT") == 0) {
            event.datatype = EDT_HEARTBEAT;

            if (IMS_SUCCESS == get_head_val("Session-Since-Startup", szcmd, LEN_512)) {
                event.event_data.heartbeat.all_session = (uint32_t)atoi(szcmd);
            }

            if (IMS_SUCCESS == get_head_val("Session-Count", szcmd, LEN_512)) {
                event.event_data.heartbeat.cur_session = (uint32_t)atoi(szcmd);
            }

            if (IMS_SUCCESS == get_head_val("Idle-CPU", szcmd, LEN_512)) {
                event.event_data.heartbeat.cpu_idle = (uint32_t)atoi(szcmd);
            }
        } else {
            event.datatype = EDT_NORMAL;
            event.event_data.normal.call_direction = FCD_UNKNOWN;
            event.event_data.normal.call_state = FCS_UNKNOWN;

            if (strcasecmp(event.name, "BACKGROUND_JOB") == 0) {
                event.event_data.normal.call_direction = FCD_OUTBOUND;
                char* fs_resp = esl_event_get_body(_handle.last_ievent);

                if (fs_resp && !is_result_ok(fs_resp)) {
                    strncpy(event.event_data.normal.reason, fs_resp + 5, LEN_128);
                    char* fs_tmp = event.event_data.normal.reason;

                    while (fs_tmp && *fs_tmp) {
                        if (*fs_tmp == '\n') {
                            *fs_tmp = '\0';
                            break;
                        }

                        fs_tmp++;
                    }

                    char tmp[LEN_512 + 1] = {0};
                    get_head_val("Job-Command-Arg", tmp, LEN_512);

                    {
                        //uuid_record error
                        char cmd[LEN_512 + 1] = {0};
                        get_head_val("Job-Command", cmd, LEN_512);
                        DEBUG_LOG("BACKGROUND_JOB: Job-Command(=%s)", cmd);

                        if (0 == strncasecmp(cmd, "uuid_record", 11)) {
                            WARNING_LOG("uuid_record failed, command-arg(=%s)", tmp);
                            continue;
                        }
                    }

                    {
                        char* tmp_start = strstr(tmp, "}");

                        if (tmp_start) {
                            char* tmp_end = strstr(tmp_start, " ");

                            if (tmp_end && tmp_end > tmp_start) {
                                strncpy(event.event_data.normal.channel_name, tmp_start + 1, tmp_end - tmp_start - 1);
                            }
                        }

                    }

                    {
                        char* tmp_sz = strstr(tmp, "IMSDATA=");

                        if (tmp_sz) {
                            tmp_sz += 8;
                            char* id_end = tmp_sz;

                            while (id_end && isdigit(*id_end)) {
                                id_end++;
                            }

                            if (id_end) {
                                *id_end = '\0';
                                event.sessionid = atoll(tmp_sz);
                                strncpy(event.name, "OPERATION_FAILED", LEN_64);
                            }
                        }
                    }
                } else {
                    ret = IMS_FAIL_TIMEOUT;
                    break;
                }
            } else {
                get_head_val("Unique-ID", event.event_data.normal.uuid, LEN_64);
                get_head_val("Caller-Caller-ID-Number", event.event_data.normal.caller_no, LEN_64);
                get_head_val("Caller-Destination-Number", event.event_data.normal.called_no, LEN_64);
                get_head_val("Channel-Name", event.event_data.normal.channel_name, LEN_64);
                std::string deviceno;

                if (strncasecmp(event.event_data.normal.channel_name, "freetdm", 7) == 0) {
                    get_head_val("variable_channel_name", event.event_data.normal.channel_name, LEN_64);
                }

                if (ims_tool_t::chlname2no(event.event_data.normal.channel_name, deviceno)) {
                    strncpy(event.event_data.normal.deviceno, deviceno.c_str(), LEN_64);
                } else {
                    event.event_data.normal.deviceno[0] = '\0';
                }

                get_head_val("Other-Leg-Unique-ID", event.event_data.normal.other_uuid, LEN_64);
                get_head_val("Other-Leg-Caller-ID-Number", event.event_data.normal.other_caller_no, LEN_64);
                get_head_val("Other-Leg-Destination-Number", event.event_data.normal.other_called_no, LEN_64);
                get_head_val("Other-Leg-Channel-Name", event.event_data.normal.other_channel_name, LEN_64);
                deviceno = "";

                if ('\0' != event.event_data.normal.other_channel_name[0]
                        && ims_tool_t::chlname2no(event.event_data.normal.other_channel_name, deviceno)) {
                    strncpy(event.event_data.normal.other_deviceno, deviceno.c_str(), LEN_64);
                } else {
                    event.event_data.normal.other_deviceno[0] = '\0';
                }

                get_head_val("Application", event.event_data.normal.application, LEN_32);
                get_head_val("Application-Data", event.event_data.normal.application_data, LEN_64);
                get_head_val("Application-Response", event.event_data.normal.application_resp, LEN_128);
                get_head_val("Hangup-Cause", event.event_data.normal.reason, LEN_128);

                if (IMS_SUCCESS == get_var("IMSDATA", szcmd, LEN_512)) {
                    event.sessionid = atoll(szcmd);
                } else {
                    event.sessionid = 0;
                }

                if (IMS_SUCCESS == get_head_val("Call-Direction", szcmd, LEN_512)) {
                    if (strcasecmp(szcmd, "outbound") == 0) {
                        event.event_data.normal.call_direction = FCD_OUTBOUND;
                    } else if (strcasecmp(szcmd, "inbound") == 0) {
                        event.event_data.normal.call_direction = FCD_INBOUND;
                    }
                }

                if (IMS_SUCCESS == get_head_val("Answer-State", szcmd, LEN_512)) {
                    if (strcasecmp(szcmd, "answered") == 0) {
                        event.event_data.normal.call_state = FCS_ANSWERED;
                    } else if (strcasecmp(szcmd, "early") == 0) {
                        event.event_data.normal.call_state = FCS_EARLY;
                    } else if (strcasecmp(szcmd, "ringing") == 0) {
                        event.event_data.normal.call_state = FCS_RING;
                    }
                }

                if (strcasecmp(event.name, "CUSTOM") == 0) {
                    char tmp[LEN_128 + 1] = {0};
                    get_head_val("Event-Subclass", tmp, LEN_128);

                    if (strcasecmp(tmp, "conference::maintenance") == 0) {
                        get_head_val("Action", tmp, LEN_128);

                        if (strcasecmp(tmp, "add-member") == 0) {
                            strncpy(event.name, "CONFERENCE_JOIN", LEN_64);
                            get_head_val("Member-ID", event.event_data.normal.ims_data, LEN_128);
                        } else if (strcasecmp(tmp, "mute-member") == 0) {
                            strncpy(event.name, "CONFERENCE_MUTE", LEN_64);
                        } else if (strcasecmp(tmp, "unmute-member") == 0) {
                            strncpy(event.name, "CONFERENCE_UNMUTE", LEN_64);
                        } else {
                            ret = IMS_FAIL_TIMEOUT;
                            break;
                        }
                    } else {
                        ret = IMS_FAIL_TIMEOUT;
                        break;
                    }
                } else if (strcasecmp(event.name, "RECORD_START") == 0) {
                    get_head_val("Record-File-Path", event.event_data.normal.ims_data, LEN_128);

                    if (strlen(event.event_data.normal.ims_data) > strlen(_recordbase)) {
                        char* ptmp = (char*)(event.event_data.normal.ims_data) + strlen(_recordbase);

                        while (ptmp && *ptmp == '/') {
                            ++ptmp;
                        }

                        std::string new_file = ptmp;
                        strncpy(event.event_data.normal.ims_data, new_file.c_str(), LEN_128);
                    }
                }
            }


            std::ostringstream ostm;
            ostm << std::endl;
            ostm << "===========================FS EVENT============================" << std::endl;
            ostm << "ID            : " << _fs_no << std::endl;
            ostm << "Address       : " << _address << ":" << _port << std::endl;
            ostm << "Time          : " << event.timestamp << std::endl;
            ostm << "SessionID     : " << event.sessionid << std::endl;
            ostm << "IMSDATA       : " << event.event_data.normal.ims_data << std::endl;
            ostm << "Name          : " << event.name << std::endl;
            ostm << "Type          : Normal" << std::endl;
            ostm << "Uuid          : " << event.event_data.normal.uuid << std::endl;;
            ostm << "CallerNo      : " << event.event_data.normal.caller_no << std::endl;;
            ostm << "CalledNo      : " << event.event_data.normal.called_no << std::endl;
            ostm << "ChannelName   : " << event.event_data.normal.channel_name << std::endl;
            ostm << "Direction     : " << event.event_data.normal.call_direction << std::endl;
            ostm << "CallState     : " << event.event_data.normal.call_state << std::endl;
            ostm << "App:          : " << event.event_data.normal.application << std::endl;
            ostm << "App_Data      : " << event.event_data.normal.application_data << std::endl;
            ostm << "App_Resp      : " << event.event_data.normal.application_resp << std::endl;
            ostm << "Other_Uuid    : " << event.event_data.normal.other_uuid << std::endl;
            ostm << "Other_Caller  : " << event.event_data.normal.other_caller_no << std::endl;
            ostm << "Other_Called  : " << event.event_data.normal.other_called_no << std::endl;
            ostm << "Other_Channel : " << event.event_data.normal.other_channel_name << std::endl;
            ostm << "Reason        : " << event.event_data.normal.reason << std::endl;
            ostm << "============================End Event============================" << std::endl;

            BGCC_TRACE("fsevent", "%s", ostm.str().c_str());
        }

        ret = IMS_SUCCESS;
        break;
    }

    //链接是好都么
    if (is_handle_valid()) {
        ret = IMS_FAIL_TIMEOUT;
        break;
    } else { // if(IMS_SUCCESS!=connect(_address,_port,_pswd,true)){
        WARNING_LOG("recv event failed(connect err)");
        ret = IMS_FAIL_CONNECT;
        break;
    }

    FUNC_END();
}
Exemple #6
0
	void CLogDeviceConsole::Write( LPCTSTR strLog )
	{
		if (!is_handle_valid(m_handle)) return;
		DWORD wrote;
		::WriteConsole(m_handle, strLog, static_cast<DWORD>(_tcslen(strLog)), &wrote, NULL);
	}