这篇教程C++ switch_true函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中switch_true函数的典型用法代码示例。如果您正苦于以下问题:C++ switch_true函数的具体用法?C++ switch_true怎么用?C++ switch_true使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了switch_true函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: event_handlerstatic void event_handler(switch_event_t *event) { const char *dest_proto = switch_event_get_header(event, "dest_proto"); const char *check_failure = switch_event_get_header(event, "Delivery-Failure"); const char *check_nonblocking = switch_event_get_header(event, "Nonblocking-Delivery"); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "skip_global_process", "true"); if (switch_true(check_failure)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Delivery Failure/n"); DUMP_EVENT(event); send_report(event, "Failure"); return; } else if ( check_failure && switch_false(check_failure) ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS Delivery Success/n"); send_report(event, "Success"); return; } else if ( check_nonblocking && switch_true(check_nonblocking) ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SMS Delivery assumed successful due to being sent in non-blocking manner/n"); send_report(event, "Accepted"); return; } switch_core_chat_send(dest_proto, event);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:26,
示例2: config_loggerstatic switch_status_t config_logger(void){ char *cf = "console.conf"; switch_xml_t cfg, xml, settings, param; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", cf); return SWITCH_STATUS_TERM; } if (log_hash) { switch_core_hash_destroy(&log_hash); } switch_core_hash_init(&log_hash, module_pool); if ((settings = switch_xml_child(cfg, "mappings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(var, val, 1); } for (param = switch_xml_child(settings, "map"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(var, val, 0); } } if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "colorize") && switch_true(val)) {#ifdef WIN32 hStdout = GetStdHandle(STD_OUTPUT_HANDLE); if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) { wOldColorAttrs = csbiInfo.wAttributes; COLORIZE = 1; }#else COLORIZE = 1;#endif } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { hard_log_level = switch_log_str2level(val); } else if (!strcasecmp(var, "uuid") && switch_true(val)) { log_uuid = SWITCH_TRUE; } } } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS;}
开发者ID:crazypenguincode,项目名称:freeswitch,代码行数:56,
示例3: do_configstatic switch_status_t do_config(void){ char *cf = "xml_rpc.conf"; switch_xml_t cfg, xml, settings, param; char *realm, *user, *pass, *default_domain; default_domain = realm = user = pass = NULL; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", cf); return SWITCH_STATUS_TERM; } globals.virtual_host = SWITCH_TRUE; if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!zstr(var) && !zstr(val)) { if (!strcasecmp(var, "auth-realm")) { realm = val; } else if (!strcasecmp(var, "auth-user")) { user = val; } else if (!strcasecmp(var, "auth-pass")) { pass = val; } else if (!strcasecmp(var, "http-port")) { globals.port = (uint16_t) atoi(val); } else if (!strcasecmp(var, "default-domain")) { default_domain = val; } else if (!strcasecmp(var, "virtual-host")) { globals.virtual_host = switch_true(val); } else if (!strcasecmp(var, "enable-websocket")) { globals.enable_websocket = switch_true(val); } } } } if (!globals.port) { globals.port = 8080; } if (realm) { set_global_realm(realm); if (user && pass) { set_global_user(user); set_global_pass(pass); } } if (default_domain) { set_global_default_domain(default_domain); } switch_xml_free(xml); return SWITCH_STATUS_SUCCESS;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:56,
示例4: print_resultvoid print_result(char const *addr, char const *port, char const *tport, double weight, unsigned preference, switch_stream_handle_t *stream){ int xml = switch_true(switch_event_get_header(stream->param_event, "xml")); if (!port || !port[0]) port = transport_is_secure(tport) ? "5061" : "5060"; if (xml) { stream->write_function(stream, " <route>/n" " <preference>%u</preference>/n" " <weight>%.3f</weight>/n" " <transport>%s</transport>/n" " <port>%s</port>/n" " <address>%s</address>/n" " </route>/n", preference, weight, tport, port, addr); } else { stream->write_function(stream, "%10u/t%10.3f/t%10s/t%10s/t%10s/n", preference, weight, tport, port, addr); }}
开发者ID:gujun,项目名称:sscore,代码行数:26,
示例5: limit_state_handlerstatic switch_status_t limit_state_handler(switch_core_session_t *session){ switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_state_t state = switch_channel_get_state(channel); const char *vval = switch_channel_get_variable(channel, LIMIT_IGNORE_TRANSFER_VARIABLE); const char *backendlist = switch_channel_get_variable(channel, LIMIT_BACKEND_VARIABLE); if (zstr(backendlist)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unset limit backendlist!/n"); return SWITCH_STATUS_SUCCESS; } if (state >= CS_HANGUP || (state == CS_ROUTING && !switch_true(vval))) { int argc = 0; char *argv[6] = { 0 }; char *mydata = strdup(backendlist); int x; argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0]))); for (x = 0; x < argc; x++) { switch_limit_release(argv[x], session, NULL, NULL); } switch_core_event_hook_remove_state_change(session, limit_state_handler); /* Remove limit_backend variable so we register another hook if limit is called again */ switch_channel_set_variable(channel, LIMIT_BACKEND_VARIABLE, NULL); free(mydata); } return SWITCH_STATUS_SUCCESS;}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:31,
示例6: load_profilestatic switch_status_t load_profile(switch_xml_t xml){ switch_xml_t param, settings; char *name = (char *) switch_xml_attr_soft(xml, "name"); logfile_profile_t *new_profile; new_profile = switch_core_alloc(module_pool, sizeof(*new_profile)); memset(new_profile, 0, sizeof(*new_profile)); switch_core_hash_init(&(new_profile->log_hash)); new_profile->name = switch_core_strdup(module_pool, switch_str_nil(name)); new_profile->suffix = 1; new_profile->log_uuid = SWITCH_TRUE; if ((settings = switch_xml_child(xml, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "logfile")) { new_profile->logfile = strdup(val); } else if (!strcmp(var, "rollover")) { new_profile->roll_size = switch_atoui(val); } else if (!strcmp(var, "maximum-rotate")) { new_profile->max_rot = switch_atoui(val); if (new_profile->max_rot == 0) { new_profile->max_rot = MAX_ROT; } } else if (!strcmp(var, "uuid")) { new_profile->log_uuid = switch_true(val); } } } if ((settings = switch_xml_child(xml, "mappings"))) { for (param = switch_xml_child(settings, "map"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); add_mapping(new_profile, var, val); } } if (zstr(new_profile->logfile)) { char logfile[512]; switch_snprintf(logfile, sizeof(logfile), "%s%s%s", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, "freeswitch.log"); new_profile->logfile = strdup(logfile); } if (mod_logfile_openlogfile(new_profile, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_GENERR; } switch_core_hash_insert_destructor(profile_hash, new_profile->name, (void *) new_profile, cleanup_profile); return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:55,
示例7: load_configstatic switch_status_t load_config(void){ char *cf = "syslog.conf"; switch_xml_t cfg, xml, settings, param; /* default log level */ log_level = SWITCH_LOG_WARNING; /* default facility */ globals.facility = DEFAULT_FACILITY; globals.log_uuid = SWITCH_TRUE; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", cf); } else { if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcmp(var, "ident")) { set_global_ident(val); } else if (!strcmp(var, "format")) { set_global_format(val); } else if (!strcmp(var, "facility")) { set_global_facility(val); } else if (!strcasecmp(var, "loglevel") && !zstr(val)) { log_level = switch_log_str2level(val); if (log_level == SWITCH_LOG_INVALID) { log_level = SWITCH_LOG_WARNING; } } else if (!strcasecmp(var, "uuid")) { globals.log_uuid = switch_true(val); } } } switch_xml_free(xml); } if (zstr(globals.ident)) { set_global_ident(DEFAULT_IDENT); } if (zstr(globals.format)) { set_global_format(DEFAULT_FORMAT); } return 0;}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:47,
示例8: vmivr_menu_purgevoid vmivr_menu_purge(switch_core_session_t *session, vmivr_profile_t *profile) { vmivr_menu_t menu = { "std_menu_purge" }; /* Initialize Menu Configs */ menu_init(profile, &menu); if (profile->id && profile->authorized) { const char *exit_purge = switch_event_get_header(menu.event_settings, "Exit-Purge"); if (switch_true(exit_purge)) { const char *cmd = switch_core_session_sprintf(session, "%s %s %s", profile->api_profile, profile->domain, profile->id); vmivr_api_execute(session, profile->api_msg_purge, cmd); } } menu_free(&menu);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:17,
示例9: pocketsphinx_asr_text_param/*! set text parameter */static void pocketsphinx_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val){ pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info; if (!zstr(param) && !zstr(val)) { if (!strcasecmp("no-input-timeout", param) && switch_is_number(val)) { ps->no_input_timeout = atoi(val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no-input-timeout = %d/n", ps->no_input_timeout); } else if (!strcasecmp("speech-timeout", param) && switch_is_number(val)) { ps->speech_timeout = atoi(val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "speech-timeout = %d/n", ps->speech_timeout); } else if (!strcasecmp("start-input-timers", param)) { ps->start_input_timers = switch_true(val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "start-input-timers = %d/n", ps->start_input_timers); } else if (!strcasecmp("confidence-threshold", param) && switch_is_number(val)) { ps->confidence_threshold = atoi(val); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "confidence-threshold = %d/n", ps->confidence_threshold); } }}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:20,
示例10: channel_receive_eventstatic switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event){ const char *command = switch_event_get_header(event, "command"); ctdm_private_t *tech_pvt = switch_core_session_get_private(session); if (!zstr(command)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM received %s command /n",command); if (!strcasecmp(command, kPREBUFFER_LEN)) { const char *szval = switch_event_get_header(event, kPREBUFFER_LEN); int val = !zstr(szval) ? atoi(szval) : 0; if (tech_pvt->prebuffer_len == val) { tech_pvt->prebuffer_len = val; if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_SET_PRE_BUFFER_SIZE, &tech_pvt->prebuffer_len)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set channel pre buffer size./n"); return SWITCH_STATUS_GENERR; } } } else if (!strcasecmp(command, kECHOCANCEL)) { const char *szval = switch_event_get_header(event, kECHOCANCEL); int enabled = !!switch_true(szval); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM sending echo cancel [%s] command /n",enabled ? "enable" : "disable"); if (FTDM_SUCCESS != ftdm_channel_command(tech_pvt->ftdm_channel, enabled ? FTDM_COMMAND_ENABLE_ECHOCANCEL : FTDM_COMMAND_DISABLE_ECHOCANCEL, NULL)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to %s echo cancellation./n", enabled ? "enable" : "disable"); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FreeTDM received unknown command [%s] /n",command); } } return SWITCH_STATUS_SUCCESS;}
开发者ID:Catorpilor,项目名称:FreeSWITCH,代码行数:37,
示例11: vmivr_menu_select_greeting_slotvoid vmivr_menu_select_greeting_slot(switch_core_session_t *session, vmivr_profile_t *profile) { vmivr_menu_t menu = { "std_select_greeting_slot" }; const char *result; int gnum = -1; /* Initialize Menu Configs */ menu_init(profile, &menu); result = vmivr_menu_get_input_set(session, profile, &menu, "X"); if (result) gnum = atoi(result); if (gnum != -1) { char * cmd = switch_core_session_sprintf(session, "%s %s %s %d", profile->api_profile, profile->domain, profile->id, gnum); if (vmivr_api_execute(session, profile->api_pref_greeting_set, cmd) == SWITCH_STATUS_SUCCESS) { char *str_num = switch_core_session_sprintf(session, "%d", gnum); char *cmd = switch_core_session_sprintf(session, "json %s %s %s %d %s", profile->api_profile, profile->domain, profile->id); switch_event_t *phrases = jsonapi2event(session, profile->api_pref_greeting_get, cmd); ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "selected_slot"), str_num, phrases, NULL, 0); if (switch_true(switch_event_get_header(phrases, "VM-Message-Private-Local-Copy"))) { const char *file_path = switch_event_get_header(phrases, "VM-Preference-Greeting-File-Path"); if (file_path && unlink(file_path) != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete temp file [%s]/n", file_path); } } switch_event_destroy(&phrases); } else { ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "invalid_slot"), NULL, NULL, NULL, 0); } } menu_free(&menu);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:36,
示例12: SWITCH_DECLARESWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session, const char *function, const char *target, switch_media_bug_callback_t callback, void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug){ switch_media_bug_t *bug, *bp; switch_size_t bytes; switch_event_t *event; int tap_only = 1, punt = 0; const char *p; if (!zstr(function)) { if ((flags & SMBF_ONE_ONLY)) { switch_thread_rwlock_wrlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { if (!zstr(bp->function) && !strcasecmp(function, bp->function)) { punt = 1; break; } } switch_thread_rwlock_unlock(session->bug_rwlock); } } if (punt) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!/n"); } if (!switch_channel_media_ready(session->channel)) { if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_FALSE; } } *new_bug = NULL; if ((p = switch_channel_get_variable(session->channel, "media_bug_answer_req")) && switch_true(p)) { flags |= SMBF_ANSWER_REQ; }#if 0 if (flags & SMBF_WRITE_REPLACE) { switch_thread_rwlock_wrlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!/n"); switch_thread_rwlock_unlock(session->bug_rwlock); return SWITCH_STATUS_GENERR; } } switch_thread_rwlock_unlock(session->bug_rwlock); } if (flags & SMBF_READ_REPLACE) { switch_thread_rwlock_wrlock(session->bug_rwlock); for (bp = session->bugs; bp; bp = bp->next) { if (switch_test_flag(bp, SMBF_READ_REPLACE)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Only one bug of this type allowed!/n"); switch_thread_rwlock_unlock(session->bug_rwlock); return SWITCH_STATUS_GENERR; } } switch_thread_rwlock_unlock(session->bug_rwlock); }#endif if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) { return SWITCH_STATUS_MEMERR; } bug->callback = callback; bug->user_data = user_data; bug->session = session; bug->flags = flags; bug->function = "N/A"; bug->target = "N/A"; switch_core_session_get_read_impl(session, &bug->read_impl); switch_core_session_get_write_impl(session, &bug->write_impl); if (function) { bug->function = switch_core_session_strdup(session, function); } if (target) { bug->target = switch_core_session_strdup(session, target); } bug->stop_time = stop_time; bytes = bug->read_impl.decoded_bytes_per_packet; if (!bug->flags) { bug->flags = (SMBF_READ_STREAM | SMBF_WRITE_STREAM);//.........这里部分代码省略.........
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:101,
示例13: channel_receive_messagestatic switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg){ crtp_private_t *tech_pvt = NULL; tech_pvt = switch_core_session_get_private(session); assert(tech_pvt != NULL); switch (msg->message_id) { case SWITCH_MESSAGE_INDICATE_DEBUG_MEDIA: { if (switch_rtp_ready(tech_pvt->rtp_session) && !zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) { switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID] = {0}; int x = 0; if (!strcasecmp(msg->string_array_arg[0], "read")) { flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++; } else if (!strcasecmp(msg->string_array_arg[0], "write")) { flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++;x++; } else if (!strcasecmp(msg->string_array_arg[0], "both")) { flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;x++; flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]++; } if (x) { if (switch_true(msg->string_array_arg[1])) { switch_rtp_set_flags(tech_pvt->rtp_session, flags); } else { switch_rtp_clear_flags(tech_pvt->rtp_session, flags); } } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid Options/n"); } } break; } case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: if (switch_rtp_ready(tech_pvt->rtp_session)) { rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE); } break; case SWITCH_MESSAGE_INDICATE_JITTER_BUFFER: { if (switch_rtp_ready(tech_pvt->rtp_session)) { int len = 0, maxlen = 0, qlen = 0, maxqlen = 50, max_drift = 0; if (msg->string_arg) { char *p, *q; const char *s; if (!strcasecmp(msg->string_arg, "pause")) { switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_TRUE); goto end; } else if (!strcasecmp(msg->string_arg, "resume")) { switch_rtp_pause_jitter_buffer(tech_pvt->rtp_session, SWITCH_FALSE); goto end; } else if (!strncasecmp(msg->string_arg, "debug:", 6)) { s = msg->string_arg + 6; if (s && !strcmp(s, "off")) { s = NULL; } switch_rtp_debug_jitter_buffer(tech_pvt->rtp_session, s); goto end; } if ((len = atoi(msg->string_arg))) { qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000); if (qlen < 1) { qlen = 3; } } if (qlen) { if ((p = strchr(msg->string_arg, ':'))) { p++; maxlen = atol(p); if ((q = strchr(p, ':'))) { q++; max_drift = abs(atol(q)); } } } if (maxlen) { maxqlen = maxlen / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000); } } if (qlen) { if (maxqlen < qlen) { maxqlen = qlen * 5; } if (switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen, maxqlen, tech_pvt->read_codec.implementation->samples_per_packet, tech_pvt->read_codec.implementation->samples_per_second, max_drift) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames) (%d max frames) (%d max drift)/n", len, qlen, maxqlen, max_drift); switch_channel_set_flag(tech_pvt->channel, CF_JITTERBUFFER);//.........这里部分代码省略.........
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:101,
示例14: sangoma_parse_configstatic int sangoma_parse_config(void){ switch_xml_t cfg, settings, param, vocallos, xml, vocallo; struct in_addr vocallo_base_ip; char ipbuff[50]; char netbuff[50]; int host_ipaddr = 0; int host_netmaskaddr = 0; int vidx = 0; int baseudp = 0; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Reading sangoma codec configuration/n"); if (!(xml = switch_xml_open_cfg(SANGOMA_TRANSCODE_CONFIG, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to open sangoma codec configuration %s/n", SANGOMA_TRANSCODE_CONFIG); return -1; } memset(&g_init_cfg, 0, sizeof(g_init_cfg)); if ((settings = switch_xml_child(cfg, "settings"))) { /* nothing here yet */ for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *)switch_xml_attr_soft(param, "name"); char *val = (char *)switch_xml_attr_soft(param, "value"); /* this parameter overrides the default list of codecs to load */ if (!strcasecmp(var, "register")) { strncpy(g_codec_register_list, val, sizeof(g_codec_register_list)-1); g_codec_register_list[sizeof(g_codec_register_list)-1] = 0; } else if (!strcasecmp(var, "noregister")) { strncpy(g_codec_noregister_list, val, sizeof(g_codec_noregister_list)-1); g_codec_noregister_list[sizeof(g_codec_noregister_list)-1] = 0; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignored unknown Sangoma codec setting %s/n", var); } } } if ((vocallos = switch_xml_child(cfg, "vocallos"))) { for (vocallo = switch_xml_child(vocallos, "vocallo"); vocallo; vocallo = vocallo->next) { const char *name = switch_xml_attr(vocallo, "name"); if (!name) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Sangoma vocallo found with no name= attribute, ignoring!/n"); continue; } if (load_nic_network_information(name, &g_init_cfg.host_nic_vocallo_cfg[vidx])) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring vocallo %s, failed to retrieve its network configuration/n", name); continue; } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Configuring vocallo %s/n", name); g_init_cfg.host_nic_vocallo_cfg[vidx].vocallo_base_udp_port = SANGOMA_DEFAULT_UDP_PORT; g_init_cfg.host_nic_vocallo_cfg[vidx].silence_suppression = 0; for (param = switch_xml_child(vocallo, "param"); param; param = param->next) { char *var = (char *)switch_xml_attr_soft(param, "name"); char *val = (char *)switch_xml_attr_soft(param, "value"); /* starting UDP port to be used by the vocallo modules */ if (!strcasecmp(var, "baseudp")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found Sangoma codec base udp port %s/n", val); baseudp = atoi(val); if (baseudp < SANGOMA_MIN_UDP_PORT || baseudp > SANGOMA_MAX_UDP_PORT) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Sangoma codec base udp port %s, using default %d/n", val, SANGOMA_DEFAULT_UDP_PORT); break; } g_init_cfg.host_nic_vocallo_cfg[vidx].vocallo_base_udp_port = baseudp; } else if (!strcasecmp(var, "vocalloaddr")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found Sangoma codec vocallo addr %s/n", val); if (switch_inet_pton(AF_INET, val, &vocallo_base_ip) <= 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Sangoma codec vocallo addr %s/n", val); break; } g_init_cfg.host_nic_vocallo_cfg[vidx].vocallo_ip = ntohl(vocallo_base_ip.s_addr); } else if (!strcasecmp(var, "silence")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found Sangoma codec silence setting %s/n", val); g_init_cfg.host_nic_vocallo_cfg[vidx].silence_suppression = switch_true(val) ? 1 : 0; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignored unknown Sangoma vocallo setting %s/n", var); } } if (!g_init_cfg.host_nic_vocallo_cfg[vidx].vocallo_ip) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Ignoring vocallo %s, no valid address was configured/n", name); continue; } host_ipaddr = htonl(g_init_cfg.host_nic_vocallo_cfg[vidx].host_ip); host_netmaskaddr = htonl(g_init_cfg.host_nic_vocallo_cfg[vidx].host_ip_netmask); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Configured Sangoma transcoding interface %s, IP address %s, netmask %s/n", name, switch_inet_ntop(AF_INET, &host_ipaddr, ipbuff, sizeof(ipbuff)), switch_inet_ntop(AF_INET, &host_netmaskaddr, netbuff, sizeof(netbuff))); strncpy(g_vocallo_names[vidx], name, sizeof(g_vocallo_names[vidx])-1); g_vocallo_names[vidx][sizeof(g_vocallo_names[vidx])-1] = 0;//.........这里部分代码省略.........
开发者ID:sl33nyc,项目名称:freeswitch,代码行数:101,
示例15: launch_threadstatic void launch_thread(const char *name, const char *path, switch_xml_t directory){ local_stream_source_t *source = NULL; switch_memory_pool_t *pool; switch_xml_t param; switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool/n"); abort(); } source = switch_core_alloc(pool, sizeof(*source)); assert(source != NULL); source->pool = pool; source->name = switch_core_strdup(source->pool, name); source->location = switch_core_strdup(source->pool, path); source->rate = 8000; source->interval = 20; source->channels = 1; source->timer_name = "soft"; source->prebuf = DEFAULT_PREBUFFER_SIZE; source->stopped = 0; source->hup = 0; source->chime_freq = 30; for (param = switch_xml_child(directory, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "rate")) { int tmp = atoi(val); if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) { source->rate = tmp; } } else if (!strcasecmp(var, "shuffle")) { source->shuffle = switch_true(val); } else if (!strcasecmp(var, "prebuf")) { int tmp = atoi(val); if (tmp > 0) { source->prebuf = (uint32_t) tmp; } } else if (!strcasecmp(var, "channels")) { int tmp = atoi(val); if (tmp == 1 || tmp == 2) { source->channels = (uint8_t) tmp; } } else if (!strcasecmp(var, "chime-freq")) { int tmp = atoi(val); if (tmp > 1) { source->chime_freq = tmp; } } else if (!strcasecmp(var, "chime-max")) { int tmp = atoi(val); if (tmp > 1) { source->chime_max = tmp; } } else if (!strcasecmp(var, "chime-list")) { char *list_dup = switch_core_strdup(source->pool, val); source->chime_total = switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0]))); } else if (!strcasecmp(var, "interval")) { int tmp = atoi(val); if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) { source->interval = tmp; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Interval must be multiple of 10 and less than %d, Using default of 20/n", SWITCH_MAX_INTERVAL); } } else if (!strcasecmp(var, "timer-name")) { source->timer_name = switch_core_strdup(source->pool, val); } } if (source->chime_max) { source->chime_max *= source->rate; } if (source->chime_total) { source->chime_counter = source->rate * source->chime_freq; } source->samples = switch_samples_per_packet(source->rate, source->interval); switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool); switch_threadattr_create(&thd_attr, source->pool); switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);}
开发者ID:crazypenguincode,项目名称:freeswitch,代码行数:89,
示例16: load_configstatic switch_status_t load_config(void){ char *cf = "enum.conf"; int inameserver = 0; switch_xml_t cfg, xml = NULL, param, settings, route, routes; switch_status_t status = SWITCH_STATUS_SUCCESS; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", cf); status = SWITCH_STATUS_FALSE; goto done; } globals.timeout = 5000; globals.retries = 3; globals.random = 0; if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { const char *var = switch_xml_attr_soft(param, "name"); const char *val = switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "default-root")) { set_global_root(val); } else if (!strcasecmp(var, "auto-reload")) { globals.auto_reload = switch_true(val); } else if (!strcasecmp(var, "query-timeout")) { globals.timeout = atoi(val) * 1000; } else if (!strcasecmp(var, "query-timeout-ms")) { globals.timeout = atoi(val); } else if (!strcasecmp(var, "query-timeout-retry")) { globals.retries = atoi(val); } else if (!strcasecmp(var, "random-nameserver")) { globals.random = switch_true(val); } else if (!strcasecmp(var, "default-isn-root")) { set_global_isn_root(val); } else if (!strcasecmp(var, "nameserver") || !strcasecmp(var, "use-server")) { if ( inameserver < ENUM_MAXNAMESERVERS ) { globals.nameserver[inameserver] = (char *) val; inameserver++; } } else if (!strcasecmp(var, "log-level-trace")) { } } } if ((routes = switch_xml_child(cfg, "routes"))) { for (route = switch_xml_child(routes, "route"); route; route = route->next) { char *service = (char *) switch_xml_attr_soft(route, "service"); char *regex = (char *) switch_xml_attr_soft(route, "regex"); char *replace = (char *) switch_xml_attr_soft(route, "replace"); if (service && regex && replace) { add_route(service, regex, replace); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Route!/n"); } } } done:#ifdef _MSC_VER if (!globals.nameserver[0]) { HKEY hKey; DWORD data_sz; char* buf; RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM//CurrentControlSet//Services//Tcpip//Parameters", 0, KEY_QUERY_VALUE, &hKey); if (hKey) { RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, NULL, &data_sz); if (data_sz) { buf = (char*)malloc(data_sz + 1); RegQueryValueEx(hKey, "DhcpNameServer", NULL, NULL, (LPBYTE)buf, &data_sz); RegCloseKey(hKey); if(buf[data_sz - 1] != 0) { buf[data_sz] = 0; } switch_replace_char(buf, ' ', 0, SWITCH_FALSE); /* only use the first entry ex "192.168.1.1 192.168.1.2" */ globals.nameserver[0] = buf; } } }#endif if (xml) { switch_xml_free(xml); } if (!globals.root) { set_global_root("e164.org"); } if (!globals.isn_root) { set_global_isn_root("freenum.org"); }//.........这里部分代码省略.........
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:101,
示例17: vmivr_menu_navigator//.........这里部分代码省略......... /* TODO check if msg is gone (purged by another session, notify user and auto jump to next message or something) */ if (!skip_header) { if (!initial_count_played) { cmd = switch_core_session_sprintf(session, "json %s %s %s", profile->api_profile, profile->domain, profile->id); jsonapi_populate_event(session, menu.phrase_params, profile->api_msg_count, cmd); initial_count_played = SWITCH_TRUE; // TODO ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "msg_count"), NULL, menu.phrase_params, NULL, 0); } if (msg_count > 0) { ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "say_msg_number"), NULL, menu.phrase_params, NULL, 0); ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "say_date"), NULL, menu.phrase_params, NULL, 0); } } if (msg_count > 0 && !skip_playback) { /* TODO Update the Read date of a message (When msg start, or when it listen compleatly ??? To be determined */ ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "play_message"), NULL, menu.phrase_params, NULL, 0); } skip_header = SWITCH_FALSE; skip_playback = SWITCH_FALSE; ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "menu_options"), NULL, menu.phrase_params, NULL, menu.ivr_entry_timeout); if (menu.ivre_d.result == RES_TIMEOUT) { ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "timeout"), NULL, NULL, NULL, 0); } else if (menu.ivre_d.result == RES_INVALID) { ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "invalid"), NULL, NULL, NULL, 0); } else if (menu.ivre_d.result == RES_FOUND) { /* Matching DTMF Key Pressed */ const char *action = switch_event_get_header(menu.event_keys_dtmf, menu.ivre_d.dtmf_stored); /* Reset the try count */ retry = menu.ivr_maximum_attempts;action: if (action) { if (!strcasecmp(action, "skip_intro")) { /* Skip Header / Play the recording again */ skip_header = SWITCH_TRUE; } else if (!strcasecmp(action, "next_msg")) { /* Next Message */ next_msg++; } else if (!strcasecmp(action, "prev_msg")) { /* Previous Message */ next_msg--; } else if (!strcasecmp(action, "delete_msg")) { /* Delete / Undelete Message */ const char *msg_flags = switch_event_get_header(menu.phrase_params, "VM-Message-Flags"); if (!msg_flags || strncasecmp(msg_flags, "delete", 6)) { const char *action_on_delete = switch_event_get_header(menu.event_settings, "Nav-Action-On-Delete"); cmd = switch_core_session_sprintf(session, "%s %s %s %s", profile->api_profile, profile->domain, profile->id, switch_event_get_header(menu.phrase_params, "VM-Message-UUID")); vmivr_api_execute(session, profile->api_msg_delete, cmd); msg_deleted = SWITCH_TRUE; if (action_on_delete) { action = action_on_delete; goto action; } else { skip_header = skip_playback = SWITCH_TRUE; } } else { cmd = switch_core_session_sprintf(session, "%s %s %s %s", profile->api_profile, profile->domain, profile->id, switch_event_get_header(menu.phrase_params, "VM-Message-UUID")); vmivr_api_execute(session, profile->api_msg_undelete, cmd); msg_undeleted = SWITCH_TRUE; } } else if (!strcasecmp(action, "save_msg")) { /* Save Message */ cmd = switch_core_session_sprintf(session, "%s %s %s %s", profile->api_profile, profile->domain, profile->id, switch_event_get_header(menu.phrase_params, "VM-Message-UUID")); vmivr_api_execute(session, profile->api_msg_save, cmd); msg_saved = SWITCH_TRUE; } else if (!strcasecmp(action, "callback")) { /* CallBack caller */ const char *cid_num = switch_event_get_header(menu.phrase_params, "VM-Message-Caller-Number"); if (cid_num) { /* TODO add detection for private number */ switch_core_session_execute_exten(session, cid_num, "XML", profile->domain); } else { /* TODO Some error msg that the msg doesn't contain a caller number */ } } else if (!strncasecmp(action, "menu:", 5)) { /* Sub Menu */ void (*fPtr)(switch_core_session_t *session, vmivr_profile_t *profile) = vmivr_get_menu_function(action+5); if (fPtr) { fPtr(session, profile); } } else if (!strcasecmp(action, "return")) { /* Return */ retry = -1; } } } /* IF the API to get the message returned us a COPY of the file menu.ivre_dally (temp file create from a DB or from a web server), delete it */ if (switch_true(switch_event_get_header(menu.phrase_params, "VM-Message-Private-Local-Copy"))) { const char *file_path = switch_event_get_header(menu.phrase_params, "VM-Message-File-Path"); if (file_path && unlink(file_path) != 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete temp file [%s]/n", file_path); } } menu_instance_free(&menu); }done: switch_event_destroy(&msg_list_params); menu_free(&menu); return;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:101,
示例18: vmivr_menu_authenticatevoid vmivr_menu_authenticate(switch_core_session_t *session, vmivr_profile_t *profile) { switch_channel_t *channel = switch_core_session_get_channel(session); vmivr_menu_t menu = { "std_authenticate" }; int retry; const char *auth_var = NULL; /* Initialize Menu Configs */ menu_init(profile, &menu); if (profile->id && (auth_var = switch_channel_get_variable(channel, "voicemail_authorized")) && switch_true(auth_var)) { profile->authorized = SWITCH_TRUE; } for (retry = menu.ivr_maximum_attempts; switch_channel_ready(channel) && retry > 0 && profile->authorized == SWITCH_FALSE; retry--) { const char *id = profile->id, *password = NULL; char *cmd = NULL; const char *password_mask = switch_event_get_header(menu.event_settings, "Password-Mask"); const char *user_mask = switch_event_get_header(menu.event_settings, "User-Mask"); if (!id) { vmivr_menu_t sub_menu = { "std_authenticate_ask_user" }; /* Initialize Menu Configs */ menu_init(profile, &sub_menu); switch_event_add_header(sub_menu.phrase_params, SWITCH_STACK_BOTTOM, "IVR-Retry-Left", "%d", retry); id = vmivr_menu_get_input_set(session, profile, &sub_menu, user_mask); menu_free(&sub_menu); } if (!password) { vmivr_menu_t sub_menu = { "std_authenticate_ask_password" }; /* Initialize Menu Configs */ menu_init(profile, &sub_menu); switch_event_add_header(sub_menu.phrase_params, SWITCH_STACK_BOTTOM, "IVR-Retry-Left", "%d", retry); password = vmivr_menu_get_input_set(session, profile, &sub_menu, password_mask); menu_free(&sub_menu); } cmd = switch_core_session_sprintf(session, "%s %s %s %s", profile->api_profile, profile->domain, id, password); if (vmivr_api_execute(session, profile->api_auth_login, cmd) == SWITCH_STATUS_SUCCESS) { profile->id = id; profile->authorized = SWITCH_TRUE; } else { ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "fail_auth"), NULL, NULL, NULL, 0); } } menu_free(&menu);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:48,
示例19: my_on_reportingstatic switch_status_t my_on_reporting(switch_core_session_t *session){ switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *channel = switch_core_session_get_channel(session); switch_event_header_t *hi; switch_caller_profile_t *caller_profile; switch_app_log_t *app_log; bson cdr; int is_b; char *tmp; if (globals.shutdown) { return SWITCH_STATUS_SUCCESS; } is_b = channel && switch_channel_get_originator_caller_profile(channel); if (!globals.log_b && is_b) { const char *force_cdr = switch_channel_get_variable(channel, SWITCH_FORCE_PROCESS_CDR_VARIABLE); if (!switch_true(force_cdr)) { return SWITCH_STATUS_SUCCESS; } } bson_init(&cdr); /* Channel data */ bson_append_start_object(&cdr, "channel_data"); bson_append_string(&cdr, "state", switch_channel_state_name(switch_channel_get_state(channel))); bson_append_string(&cdr, "direction", switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); bson_append_int(&cdr, "state_number", switch_channel_get_state(channel)); if ((tmp = switch_channel_get_flag_string(channel))) { bson_append_string(&cdr, "flags", tmp); free(tmp); } if ((tmp = switch_channel_get_cap_string(channel))) { bson_append_string(&cdr, "caps", tmp); free(tmp); } bson_append_finish_object(&cdr); /* channel_data */ /* Channel variables */ bson_append_start_object(&cdr, "variables"); if ((hi = switch_channel_variable_first(channel))) { for (; hi; hi = hi->next) { if (!zstr(hi->name) && !zstr(hi->value)) { bson_append_string(&cdr, hi->name, hi->value); } } switch_channel_variable_last(channel); } bson_append_finish_object(&cdr); /* variables */ /* App log */ if ((app_log = switch_core_session_get_app_log(session))) { switch_app_log_t *ap; bson_append_start_object(&cdr, "app_log"); for (ap = app_log; ap; ap = ap->next) { bson_append_start_object(&cdr, "application"); bson_append_string(&cdr, "app_name", ap->app); bson_append_string(&cdr, "app_data", ap->arg); bson_append_long(&cdr, "app_stamp", ap->stamp); bson_append_finish_object(&cdr); /* application */ } bson_append_finish_object(&cdr); /* app_log */ } /* Callflow */ caller_profile = switch_channel_get_caller_profile(channel); while (caller_profile) { bson_append_start_object(&cdr, "callflow"); if (!zstr(caller_profile->dialplan)) { bson_append_string(&cdr, "dialplan", caller_profile->dialplan); } if (!zstr(caller_profile->profile_index)) { bson_append_string(&cdr, "profile_index", caller_profile->profile_index); } if (caller_profile->caller_extension) { switch_caller_application_t *ap; bson_append_start_object(&cdr, "extension"); bson_append_string(&cdr, "name", caller_profile->caller_extension->extension_name); bson_append_string(&cdr, "number", caller_profile->caller_extension->extension_number); if (caller_profile->caller_extension->current_application) { bson_append_string(&cdr, "current_app", caller_profile->caller_extension->current_application->application_name); }//.........这里部分代码省略.........
开发者ID:vkrikun,项目名称:freeswitch,代码行数:101,
示例20: switch_silk_fmtp_parsestatic switch_status_t switch_silk_fmtp_parse(const char *fmtp, switch_codec_fmtp_t *codec_fmtp){ if (codec_fmtp) { silk_codec_settings_t *codec_settings = NULL; if (codec_fmtp->private_info) { codec_settings = codec_fmtp->private_info; memcpy(codec_settings, &default_codec_settings, sizeof(*codec_settings)); } if (fmtp) { int x, argc; char *argv[10]; char *fmtp_dup = strdup(fmtp); switch_assert(fmtp_dup); argc = switch_separate_string(fmtp_dup, ';', argv, (sizeof(argv) / sizeof(argv[0]))); for (x = 0; x < argc; x++) { char *data = argv[x]; char *arg; switch_assert(data); while (*data == ' ') { data++; } if ((arg = strchr(data, '='))) { *arg++ = '/0'; if (codec_settings) { if (!strcasecmp(data, "useinbandfec")) { if (switch_true(arg)) { codec_settings->useinbandfec = 1; } } if (!strcasecmp(data, "usedtx")) { if (switch_true(arg)) { codec_settings->usedtx = 1; } } if (!strcasecmp(data, "maxaveragebitrate")) { codec_settings->maxaveragebitrate = atoi(arg); switch(codec_fmtp->actual_samples_per_second) { case 8000: { if(codec_settings->maxaveragebitrate < 6000 || codec_settings->maxaveragebitrate > 20000) { codec_settings->maxaveragebitrate = 20000; } break; } case 12000: { if(codec_settings->maxaveragebitrate < 7000 || codec_settings->maxaveragebitrate > 25000) { codec_settings->maxaveragebitrate = 25000; } break; } case 16000: { if(codec_settings->maxaveragebitrate < 8000 || codec_settings->maxaveragebitrate > 30000) { codec_settings->maxaveragebitrate = 30000; } break; } case 24000: { if(codec_settings->maxaveragebitrate < 12000 || codec_settings->maxaveragebitrate > 40000) { codec_settings->maxaveragebitrate = 40000; } break; } default: /* this should never happen but 20000 is common among all rates */ codec_settings->maxaveragebitrate = 20000; break; } } } } } free(fmtp_dup); } //codec_fmtp->bits_per_second = bit_rate; return SWITCH_STATUS_SUCCESS; } return SWITCH_STATUS_FALSE;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:88,
示例21: populate_databasestatic switch_status_t populate_database(switch_core_session_t *session, dir_profile_t *profile, const char *domain_name){ switch_status_t status = SWITCH_STATUS_SUCCESS; char *sql = NULL; char *sqlvalues = NULL; char *sqltmp = NULL; int count = 0; switch_xml_t xml_root = NULL, x_domain; switch_xml_t ut; switch_event_t *xml_params = NULL; switch_xml_t group = NULL, groups = NULL, users = NULL, x_params = NULL, x_param = NULL, x_vars = NULL, x_var = NULL; switch_event_create(&xml_params, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(xml_params); if (switch_xml_locate_domain(domain_name, xml_params, &xml_root, &x_domain) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate domain %s/n", domain_name); status = SWITCH_STATUS_FALSE; goto end; } if ((groups = switch_xml_child(x_domain, "groups"))) { for (group = switch_xml_child(groups, "group"); group; group = group->next) { if ((users = switch_xml_child(group, "users"))) { for (ut = switch_xml_child(users, "user"); ut; ut = ut->next) { int name_visible = 1; int exten_visible = 1; const char *type = switch_xml_attr_soft(ut, "type"); const char *id = switch_xml_attr_soft(ut, "id"); char *fullName = NULL; char *caller_name = NULL; char *caller_name_override = NULL; char *firstName = NULL; char *lastName = NULL; char *fullNameDigit = NULL; char *firstNameDigit = NULL; char *lastNameDigit = NULL; if (!strcasecmp(type, "pointer")) { continue; } /* Check all the user params */ if ((x_params = switch_xml_child(ut, "params"))) { for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) { const char *var = switch_xml_attr_soft(x_param, "name"); const char *val = switch_xml_attr_soft(x_param, "value"); if (!strcasecmp(var, "directory-visible")) { name_visible = switch_true(val); } if (!strcasecmp(var, "directory-exten-visible")) { exten_visible = switch_true(val); } } } /* Check all the user variables */ if ((x_vars = switch_xml_child(ut, "variables"))) { for (x_var = switch_xml_child(x_vars, "variable"); x_var; x_var = x_var->next) { const char *var = switch_xml_attr_soft(x_var, "name"); const char *val = switch_xml_attr_soft(x_var, "value"); if (!strcasecmp(var, "effective_caller_id_name")) { caller_name = switch_core_session_strdup(session, val); } if (!strcasecmp(var, "directory_full_name")) { caller_name_override = switch_core_session_strdup(session, val); } } } if (caller_name_override) { fullName = caller_name_override; } else { fullName = caller_name; } if (zstr(fullName)) { continue; } firstName = switch_core_session_strdup(session, fullName); if ((lastName = strrchr(firstName, ' '))) { *lastName++ = '/0'; } else { lastName = switch_core_session_strdup(session, firstName); } /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "FullName %s firstName [%s] lastName [%s]/n", fullName, firstName, lastName); */ /* Generate Digits key mapping */ fullNameDigit = string_to_keypad_digit(fullName); lastNameDigit = string_to_keypad_digit(lastName); firstNameDigit = string_to_keypad_digit(firstName); /* add user into DB */ sql = switch_mprintf("insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')", globals.hostname, switch_core_session_get_uuid(session), id, fullName, fullNameDigit, firstName, firstNameDigit, lastName, lastNameDigit, name_visible, exten_visible); if (sqlvalues) { sqltmp = sqlvalues;//.........这里部分代码省略.........
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:101,
示例22: load_configstatic switch_status_t load_config(switch_memory_pool_t *pool){ char *cf = "cdr_csv.conf"; switch_xml_t cfg, xml, settings, param; switch_status_t status = SWITCH_STATUS_SUCCESS; memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.fd_hash, pool); switch_core_hash_init(&globals.template_hash, pool); globals.pool = pool; switch_core_hash_insert(globals.template_hash, "default", default_template); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template./n"); globals.legs = CDR_LEG_A; if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "debug")) { globals.debug = switch_true(val); } else if (!strcasecmp(var, "legs")) { globals.legs = 0; if (strchr(val, 'a')) { globals.legs |= CDR_LEG_A; } if (strchr(val, 'b')) { globals.legs |= CDR_LEG_B; } } else if (!strcasecmp(var, "log-base")) { globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", val, SWITCH_PATH_SEPARATOR); } else if (!strcasecmp(var, "rotate-on-hup")) { globals.rotate = switch_true(val); } else if (!strcasecmp(var, "default-template")) { globals.default_template = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "master-file-only")) { globals.masterfileonly = switch_true(val); } } } if ((settings = switch_xml_child(cfg, "templates"))) { for (param = switch_xml_child(settings, "template"); param; param = param->next) { char *var = (char *) switch_xml_attr(param, "name"); if (var) { char *tpl; size_t len = strlen(param->txt) + 2; if (end_of(param->txt) != '/n') { tpl = switch_core_alloc(pool, len); switch_snprintf(tpl, len, "%s/n", param->txt); } else { tpl = switch_core_strdup(pool, param->txt); } switch_core_hash_insert(globals.template_hash, var, tpl); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s./n", var); } } } switch_xml_free(xml); } if (zstr(globals.default_template)) { globals.default_template = switch_core_strdup(pool, "default"); } if (!globals.log_dir) { globals.log_dir = switch_core_sprintf(pool, "%s%scdr-csv", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR); } return status;}
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:78,
示例23: do_configstatic switch_status_t do_config(void){ char *cf = "xml_curl.conf"; switch_xml_t cfg, xml, bindings_tag, binding_tag, param; xml_binding_t *binding = NULL; int x = 0; int need_vars_map = 0; switch_hash_t *vars_map = NULL; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed/n", cf); return SWITCH_STATUS_TERM; } if (!(bindings_tag = switch_xml_child(cfg, "bindings"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <bindings> tag!/n"); goto done; } for (binding_tag = switch_xml_child(bindings_tag, "binding"); binding_tag; binding_tag = binding_tag->next) { char *bname = (char *) switch_xml_attr_soft(binding_tag, "name"); char *url = NULL; char *bind_cred = NULL; char *bind_mask = NULL; char *method = NULL; int disable100continue = 1; int use_dynamic_url = 0, timeout = 0; uint32_t enable_cacert_check = 0; char *ssl_cert_file = NULL; char *ssl_key_file = NULL; char *ssl_key_password = NULL; char *ssl_version = NULL; char *ssl_cacert_file = NULL; uint32_t enable_ssl_verifyhost = 0; char *cookie_file = NULL; hash_node_t *hash_node; int auth_scheme = CURLAUTH_BASIC; need_vars_map = 0; vars_map = NULL; for (param = switch_xml_child(binding_tag, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "gateway-url")) { bind_mask = (char *) switch_xml_attr_soft(param, "bindings"); if (val) { url = val; } } else if (!strcasecmp(var, "gateway-credentials")) { bind_cred = val; } else if (!strcasecmp(var, "auth-scheme")) { if (*val == '=') { auth_scheme = 0; val++; } if (!strcasecmp(val, "basic")) { auth_scheme |= CURLAUTH_BASIC; } else if (!strcasecmp(val, "digest")) { auth_scheme |= CURLAUTH_DIGEST; } else if (!strcasecmp(val, "NTLM")) { auth_scheme |= CURLAUTH_NTLM; } else if (!strcasecmp(val, "GSS-NEGOTIATE")) { auth_scheme |= CURLAUTH_GSSNEGOTIATE; } else if (!strcasecmp(val, "any")) { auth_scheme = CURLAUTH_ANY; } } else if (!strcasecmp(var, "disable-100-continue") && !switch_true(val)) { disable100continue = 0; } else if (!strcasecmp(var, "method")) { method = val; } else if (!strcasecmp(var, "timeout")) { int tmp = atoi(val); if (tmp >= 0) { timeout = tmp; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set a negative timeout!/n"); } } else if (!strcasecmp(var, "enable-cacert-check") && switch_true(val)) { enable_cacert_check = 1; } else if (!strcasecmp(var, "ssl-cert-path")) { ssl_cert_file = val; } else if (!strcasecmp(var, "ssl-key-path")) { ssl_key_file = val; } else if (!strcasecmp(var, "ssl-key-password")) { ssl_key_password = val; } else if (!strcasecmp(var, "ssl-version")) { ssl_version = val; } else if (!strcasecmp(var, "ssl-cacert-file")) { ssl_cacert_file = val; } else if (!strcasecmp(var, "enable-ssl-verifyhost") && switch_true(val)) { enable_ssl_verifyhost = 1; } else if (!strcasecmp(var, "cookie-file")) { cookie_file = val; } else if (!strcasecmp(var, "use-dynamic-url") && switch_true(val)) { use_dynamic_url = 1; } else if (!strcasecmp(var, "enable-post-var")) { if (!vars_map && need_vars_map == 0) {//.........这里部分代码省略.........
开发者ID:kgrofelnik,项目名称:mod_portaudio-endpoints,代码行数:101,
示例24: fileman_file_open/** * Wraps file with interface that can be controlled by fileman flags * @param handle * @param path the file to play * @return SWITCH_STATUS_SUCCESS if opened */static switch_status_t fileman_file_open(switch_file_handle_t *handle, const char *path){ int start_offset_ms = 0; switch_status_t status = SWITCH_STATUS_FALSE; struct fileman_file_context *context = switch_core_alloc(handle->memory_pool, sizeof(*context)); handle->private_info = context; if (handle->params) { const char *id = switch_event_get_header(handle->params, "id"); const char *uuid = switch_event_get_header(handle->params, "session"); const char *start_offset_ms_str = switch_event_get_header(handle->params, "start_offset_ms"); if (!zstr(id)) { context->id = switch_core_strdup(handle->memory_pool, id); } if (!zstr(uuid)) { context->uuid = switch_core_strdup(handle->memory_pool, uuid); } if (!zstr(start_offset_ms_str) && switch_is_number(start_offset_ms_str)) { start_offset_ms = atoi(start_offset_ms_str); if (start_offset_ms < 0) { start_offset_ms = 0; } } } switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "Got path %s/n", path); if ((status = switch_core_file_open(&context->fh, path, handle->channels, handle->samplerate, handle->flags, NULL)) != SWITCH_STATUS_SUCCESS) { return status; } /* set up handle for external control */ if (!context->id) { /* use filename as ID */ context->id = switch_core_strdup(handle->memory_pool, path); } switch_mutex_lock(fileman_globals.mutex); if (!switch_core_hash_find(fileman_globals.hash, context->id)) { switch_core_hash_insert(fileman_globals.hash, context->id, handle); } else { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_WARNING, "Duplicate fileman ID: %s/n", context->id); return SWITCH_STATUS_FALSE; } switch_mutex_unlock(fileman_globals.mutex); context->max_frame_len = (handle->samplerate / 1000 * SWITCH_MAX_INTERVAL); switch_zmalloc(context->abuf, FILE_STARTBYTES * sizeof(*context->abuf)); if (!context->fh.audio_buffer) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "Create audio buffer/n"); switch_buffer_create_dynamic(&context->fh.audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0); switch_assert(context->fh.audio_buffer); } handle->samples = context->fh.samples; handle->format = context->fh.format; handle->sections = context->fh.sections; handle->seekable = context->fh.seekable; handle->speed = context->fh.speed; handle->vol = context->fh.vol; handle->offset_pos = context->fh.offset_pos; handle->interval = context->fh.interval; if (switch_test_flag((&context->fh), SWITCH_FILE_NATIVE)) { switch_set_flag(handle, SWITCH_FILE_NATIVE); } else { switch_clear_flag(handle, SWITCH_FILE_NATIVE); } if (handle->params && switch_true(switch_event_get_header(handle->params, "pause"))) { switch_set_flag(handle, SWITCH_FILE_PAUSE); } if (handle->seekable && start_offset_ms) { unsigned int pos = 0; int32_t target = start_offset_ms * (handle->samplerate / 1000); switch_log_printf(SWITCH_CHANNEL_UUID_LOG(context->uuid), SWITCH_LOG_DEBUG, "seek to position %d/n", target); switch_core_file_seek(&context->fh, &pos, target, SEEK_SET); } return status;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:88,
示例25: channel_write_framestatic switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id){ switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; switch_status_t status = SWITCH_STATUS_FALSE; channel = switch_core_session_get_channel(session); switch_assert(channel != NULL); tech_pvt = switch_core_session_get_private(session); switch_assert(tech_pvt != NULL); if (switch_test_flag(frame, SFF_CNG) || switch_test_flag(tech_pvt, TFLAG_CNG) || switch_test_flag(tech_pvt, TFLAG_BOWOUT)) { return SWITCH_STATUS_SUCCESS; } switch_mutex_lock(tech_pvt->mutex); if (!switch_test_flag(tech_pvt, TFLAG_BOWOUT) && tech_pvt->other_tech_pvt && switch_test_flag(tech_pvt, TFLAG_BRIDGE) && switch_test_flag(tech_pvt->other_tech_pvt, TFLAG_BRIDGE) && switch_channel_test_flag(tech_pvt->channel, CF_BRIDGED) && switch_channel_test_flag(tech_pvt->other_channel, CF_BRIDGED) && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) && switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) && !--tech_pvt->bowout_frame_count <= 0) { const char *a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE); const char *b_uuid = switch_channel_get_variable(tech_pvt->other_channel, SWITCH_SIGNAL_BOND_VARIABLE); const char *vetoa, *vetob; switch_set_flag_locked(tech_pvt, TFLAG_BOWOUT); switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_BOWOUT); vetoa = switch_channel_get_variable(tech_pvt->channel, "loopback_bowout"); vetob = switch_channel_get_variable(tech_pvt->other_tech_pvt->channel, "loopback_bowout"); if ((!vetoa || switch_true(vetoa)) && (!vetob || switch_true(vetob))) { switch_clear_flag_locked(tech_pvt, TFLAG_WRITE); switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE); if (a_uuid && b_uuid) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s detected bridge on both ends, attempting direct connection./n", switch_channel_get_name(channel)); /* channel_masquerade eat your heart out....... */ switch_ivr_uuid_bridge(a_uuid, b_uuid); switch_mutex_unlock(tech_pvt->mutex); return SWITCH_STATUS_SUCCESS; } } } if (switch_test_flag(tech_pvt, TFLAG_LINKED) && tech_pvt->other_tech_pvt) { switch_frame_t *clone; if (frame->codec->implementation != tech_pvt->write_codec.implementation) { /* change codecs to match */ tech_init(tech_pvt, session, frame->codec); tech_init(tech_pvt->other_tech_pvt, tech_pvt->other_session, frame->codec); } if (switch_queue_size(tech_pvt->other_tech_pvt->frame_queue) < FRAME_QUEUE_LEN) { if (switch_frame_dup(frame, &clone) != SWITCH_STATUS_SUCCESS) { abort(); } if (switch_queue_trypush(tech_pvt->other_tech_pvt->frame_queue, clone) != SWITCH_STATUS_SUCCESS) { switch_frame_free(&clone); } switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE); } status = SWITCH_STATUS_SUCCESS; } switch_mutex_unlock(tech_pvt->mutex); return status;}
开发者ID:gujun,项目名称:sscore,代码行数:79,
示例26: load_configstatic switch_status_t load_config(switch_memory_pool_t *pool){ char *cf = "cdr_sqlite.conf"; switch_xml_t cfg, xml, settings, param; switch_cache_db_handle_t *dbh = NULL; char *select_sql = NULL, *create_sql = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; memset(&globals, 0, sizeof(globals)); switch_core_hash_init(&globals.template_hash, pool); globals.pool = pool; switch_core_hash_insert(globals.template_hash, "default", default_template); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template./n"); globals.legs = CDR_LEG_A; if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) { if ((settings = switch_xml_child(cfg, "settings"))) { for (param = switch_xml_child(settings, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); if (!strcasecmp(var, "debug")) { globals.debug = switch_true(val); } else if (!strcasecmp(var, "db-name")) { globals.db_name = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "db-table")) { globals.db_table = switch_core_strdup(pool, val); } else if (!strcasecmp(var, "legs")) { globals.legs = 0; if (strchr(val, 'a')) { globals.legs |= CDR_LEG_A; } if (strchr(val, 'b')) { globals.legs |= CDR_LEG_B; } } else if (!strcasecmp(var, "default-template")) { globals.default_template = switch_core_strdup(pool, val); } } } if ((settings = switch_xml_child(cfg, "templates"))) { for (param = switch_xml_child(settings, "template"); param; param = param->next) { char *var = (char *) switch_xml_attr(param, "name"); if (var) { char *tpl; tpl = switch_core_strdup(pool, param->txt); switch_core_hash_insert(globals.template_hash, var, tpl); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding template %s./n", var); } } } switch_xml_free(xml); } if (zstr(globals.db_name)) { globals.db_name = switch_core_strdup(pool, "cdr"); } if (zstr(globals.db_table)) { globals.db_table = switch_core_strdup(pool, "cdr"); } if (zstr(globals.default_template)) { globals.default_template = switch_core_strdup(pool, "default"); } dbh = cdr_get_db_handle(); if (dbh) { select_sql = switch_mprintf("SELECT * FROM %s LIMIT 1", globals.db_table); assert(select_sql); create_sql = switch_mprintf(default_create_sql, globals.db_table); assert(create_sql); /* Check if table exists (try SELECT FROM ...) and create table if query fails */ switch_cache_db_test_reactive(dbh, select_sql, NULL, create_sql); switch_safe_free(select_sql); switch_safe_free(create_sql); switch_cache_db_release_db_handle(&dbh); } return status;}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:91,
示例27: on_execute_complete_event/** * Handle fax completion event from FreeSWITCH core * @param event received from FreeSWITCH core. It will be destroyed by the core after this function returns. */static void on_execute_complete_event(switch_event_t *event){ const char *application = switch_event_get_header(event, "Application"); if (!zstr(application) && (!strcmp(application, "rxfax") || !strcmp(application, "txfax"))) { int is_rxfax = !strcmp(application, "rxfax"); const char *uuid = switch_event_get_header(event, "Unique-ID"); const char *fax_jid = switch_event_get_header(event, "variable_rayo_fax_jid"); struct rayo_actor *component; if (!zstr(fax_jid) && (component = RAYO_LOCATE(fax_jid))) { iks *result; iks *complete; iks *fax; int have_fax_document = 1; switch_core_session_t *session; switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got result for %s/n", fax_jid); /* clean up channel */ session = switch_core_session_locate(uuid); if (session) { switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL); switch_core_session_rwunlock(session); } /* RX only: transfer HTTP document and delete local copy */ if (is_rxfax && RECEIVEFAX_COMPONENT(component)->http_put_after_receive && switch_file_exists(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)) == SWITCH_STATUS_SUCCESS) { switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s/n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename); switch_api_execute("http_put", RECEIVEFAX_COMPONENT(component)->filename, NULL, &stream); /* check if successful */ if (!zstr(stream.data) && strncmp(stream.data, "+OK", 3)) { /* PUT failed */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s failed: %s/n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename, (char *)stream.data); have_fax_document = 0; } switch_safe_free(stream.data) switch_file_remove(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)); } /* successful fax? */ if (have_fax_document && switch_true(switch_event_get_header(event, "variable_fax_success"))) { result = rayo_component_create_complete_event(RAYO_COMPONENT(component), FAX_FINISH); } else if (have_fax_document && FAX_COMPONENT(component)->stop) { result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); } else { result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR); } complete = iks_find(result, "complete"); /* RX only: add fax document information */ if (is_rxfax && have_fax_document) { const char *pages = switch_event_get_header(event, "variable_fax_document_transferred_pages"); if (!zstr(pages) && switch_is_number(pages) && atoi(pages) > 0) { const char *resolution = switch_event_get_header(event, "variable_fax_file_image_resolution"); const char *size = switch_event_get_header(event, "variable_fax_image_size"); fax = iks_insert(complete, "fax"); iks_insert_attrib(fax, "xmlns", RAYO_FAX_COMPLETE_NS); if (RECEIVEFAX_COMPONENT(component)->http_put_after_receive) { iks_insert_attrib(fax, "url", RECEIVEFAX_COMPONENT(component)->filename); } else { /* convert absolute path to file:// URI */ iks_insert_attrib_printf(fax, "url", "file://%s", RECEIVEFAX_COMPONENT(component)->filename); } if (!zstr(resolution)) { iks_insert_attrib(fax, "resolution", resolution); } if (!zstr(size)) { iks_insert_attrib(fax, "size", size); } iks_insert_attrib(fax, "pages", pages); } } /* add metadata from event */ insert_fax_metadata(event, "fax_success", complete); insert_fax_metadata(event, "fax_result_code", complete); insert_fax_metadata(event, "fax_result_text", complete); insert_fax_metadata(event, "fax_document_transferred_pages", complete); insert_fax_metadata(event, "fax_document_total_pages", complete); insert_fax_metadata(event, "fax_image_resolution", complete); insert_fax_metadata(event, "fax_image_size", complete); insert_fax_metadata(event, "fax_bad_rows", complete); insert_fax_metadata(event, "fax_transfer_rate", complete); insert_fax_metadata(event, "fax_ecm_used", complete); insert_fax_metadata(event, "fax_local_station_id", complete); insert_fax_metadata(event, "fax_remote_station_id", complete); /* flag faxing as done */ rayo_call_set_faxing(RAYO_CALL(RAYO_COMPONENT(component)->parent), 0); rayo_component_send_complete_event(RAYO_COMPONENT(component), result);//.........这里部分代码省略.........
开发者ID:lzcykevin,项目名称:FreeSWITCH,代码行数:101,
注:本文中的switch_true函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ switch_xml_attr_soft函数代码示例 C++ switch_thread_rwlock_wrlock函数代码示例 |