change low res sleep func api names

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11486 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-01-25 21:23:07 +00:00
parent 1973ee74bc
commit 0463541d61
49 changed files with 180 additions and 180 deletions

View File

@ -1690,14 +1690,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, cons
SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name); SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name);
SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname); SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname);
SWITCH_DECLARE(switch_time_t) switch_timestamp_now(void); SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void);
SWITCH_DECLARE(void) switch_core_memory_reclaim(void); SWITCH_DECLARE(void) switch_core_memory_reclaim(void);
SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void);
SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void);
SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void);
SWITCH_DECLARE(void) switch_core_setrlimits(void); SWITCH_DECLARE(void) switch_core_setrlimits(void);
SWITCH_DECLARE(void) switch_time_sync(void); SWITCH_DECLARE(void) switch_time_sync(void);
SWITCH_DECLARE(time_t) switch_timestamp(time_t *t); SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t);
SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime); SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime);
SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime); SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime);
SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload); SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload);

View File

@ -1384,13 +1384,13 @@ SWITCH_STANDARD_API(tone_detect_session_function)
uint32_t mto; uint32_t mto;
if (*argv[4] == '+') { if (*argv[4] == '+') {
if ((mto = atoi(argv[4] + 1)) > 0) { if ((mto = atoi(argv[4] + 1)) > 0) {
to = switch_timestamp(NULL) + mto; to = switch_epoch_time_now(NULL) + mto;
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
goto done; goto done;
} }
} else { } else {
if ((to = atoi(argv[4])) < switch_timestamp(NULL)) { if ((to = atoi(argv[4])) < switch_epoch_time_now(NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
to = 0; to = 0;
goto done; goto done;
@ -1520,7 +1520,7 @@ SWITCH_STANDARD_API(sched_transfer_function)
time_t when; time_t when;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -1558,7 +1558,7 @@ SWITCH_STANDARD_API(sched_hangup_function)
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -1665,7 +1665,7 @@ SWITCH_STANDARD_API(sched_broadcast_function)
time_t when; time_t when;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -2205,7 +2205,7 @@ static void sch_api_callback(switch_scheduler_task_t *task)
switch_safe_free(cmd); switch_safe_free(cmd);
if (api_task->recur) { if (api_task->recur) {
task->runtime = switch_timestamp(NULL) + api_task->recur; task->runtime = switch_epoch_time_now(NULL) + api_task->recur;
} }
@ -2252,10 +2252,10 @@ SWITCH_STANDARD_API(sched_api_function)
if (*tm == '+') { if (*tm == '+') {
when = switch_timestamp(NULL) + atol(tm + 1); when = switch_epoch_time_now(NULL) + atol(tm + 1);
} else if (*tm == '@') { } else if (*tm == '@') {
recur = (uint32_t) atol(tm + 1); recur = (uint32_t) atol(tm + 1);
when = switch_timestamp(NULL) + recur; when = switch_epoch_time_now(NULL) + recur;
} else { } else {
when = atol(tm); when = atol(tm);
} }

View File

@ -473,7 +473,7 @@ SWITCH_STANDARD_APP(sched_transfer_function)
time_t when; time_t when;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -498,7 +498,7 @@ SWITCH_STANDARD_APP(sched_hangup_function)
switch_bool_t bleg = SWITCH_FALSE; switch_bool_t bleg = SWITCH_FALSE;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -530,7 +530,7 @@ SWITCH_STANDARD_APP(sched_broadcast_function)
switch_media_flag_t flags = SMF_NONE; switch_media_flag_t flags = SMF_NONE;
if (*argv[0] == '+') { if (*argv[0] == '+') {
when = switch_timestamp(NULL) + atol(argv[0] + 1); when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else { } else {
when = atol(argv[0]); when = atol(argv[0]);
} }
@ -981,7 +981,7 @@ SWITCH_STANDARD_APP(strftime_function)
switch_time_exp_t tm; switch_time_exp_t tm;
char date[80] = ""; char date[80] = "";
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime(date, &retsize, sizeof(date), argv[1], &tm); switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
switch_channel_set_variable(switch_core_session_get_channel(session), argv[0], date); switch_channel_set_variable(switch_core_session_get_channel(session), argv[0], date);
@ -993,7 +993,7 @@ SWITCH_STANDARD_API(strepoch_api_function)
switch_time_t out; switch_time_t out;
if (switch_strlen_zero(cmd)) { if (switch_strlen_zero(cmd)) {
out = switch_timestamp_now(); out = switch_micro_time_now();
} else { } else {
out = switch_str_time(cmd); out = switch_str_time(cmd);
} }
@ -1014,7 +1014,7 @@ SWITCH_STANDARD_API(strftime_api_function)
thetime = switch_time_make(atoi(cmd), 0); thetime = switch_time_make(atoi(cmd), 0);
cmd = p + 1; cmd = p + 1;
} else { } else {
thetime = switch_timestamp_now(); thetime = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, thetime); switch_time_exp_lt(&tm, thetime);
if (switch_strlen_zero(cmd)) { if (switch_strlen_zero(cmd)) {
@ -1207,12 +1207,12 @@ SWITCH_STANDARD_APP(tone_detect_session_function)
uint32_t mto; uint32_t mto;
if (*argv[3] == '+') { if (*argv[3] == '+') {
if ((mto = atol(argv[3] + 1)) > 0) { if ((mto = atol(argv[3] + 1)) > 0) {
to = switch_timestamp(NULL) + mto; to = switch_epoch_time_now(NULL) + mto;
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
} }
} else { } else {
if ((to = atol(argv[3])) < switch_timestamp(NULL)) { if ((to = atol(argv[3])) < switch_epoch_time_now(NULL)) {
if (to >= 1) { if (to >= 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
} }

View File

@ -531,7 +531,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results
tv.tv_sec = i; tv.tv_sec = i;
tv.tv_usec = 0; tv.tv_usec = 0;
i = select((int) (fd + 1), &fds, 0, 0, &tv); i = select((int) (fd + 1), &fds, 0, 0, &tv);
now = switch_timestamp(NULL); now = switch_epoch_time_now(NULL);
if (i > 0) { if (i > 0) {
dns_ioevent(nctx, now); dns_ioevent(nctx, now);
} }

View File

@ -205,7 +205,7 @@ SWITCH_STANDARD_APP(bcast_function)
} }
} }
control_packet.unique_id = htonl((u_long) switch_timestamp(NULL)); control_packet.unique_id = htonl((u_long) switch_epoch_time_now(NULL));
control_packet.command = htonl(LS_START_BCAST); control_packet.command = htonl(LS_START_BCAST);
control_packet.ip = inet_addr(mcast_ip); control_packet.ip = inet_addr(mcast_ip);
control_packet.port = htonl(mcast_port); control_packet.port = htonl(mcast_port);
@ -233,7 +233,7 @@ SWITCH_STANDARD_APP(bcast_function)
} }
} }
control_packet.unique_id = htonl((u_long) switch_timestamp(NULL)); control_packet.unique_id = htonl((u_long) switch_epoch_time_now(NULL));
control_packet.command = htonl(LS_STOP_BCAST); control_packet.command = htonl(LS_STOP_BCAST);
bytes = 8; bytes = 8;
switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes); switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes);

View File

@ -195,7 +195,7 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (cd->total && switch_timestamp(NULL) >= cd->next) { if (cd->total && switch_epoch_time_now(NULL) >= cd->next) {
if (cd->index == MAX_CHIME || cd->index == cd->total || !cd->list[cd->index]) { if (cd->index == MAX_CHIME || cd->index == cd->total || !cd->list[cd->index]) {
cd->index = 0; cd->index = 0;
} }
@ -213,10 +213,10 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session
cd->abort = 1; cd->abort = 1;
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
cd->next = switch_timestamp(NULL) + cd->freq; cd->next = switch_epoch_time_now(NULL) + cd->freq;
cd->index++; cd->index++;
} }
} else if (cd->orbit_timeout && switch_timestamp(NULL) >= cd->orbit_timeout) { } else if (cd->orbit_timeout && switch_epoch_time_now(NULL) >= cd->orbit_timeout) {
cd->do_orbit = 1; cd->do_orbit = 1;
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -418,7 +418,7 @@ static switch_status_t hanguphook(switch_core_session_t *session)
if (state == CS_HANGUP || state == CS_ROUTING) { if (state == CS_HANGUP || state == CS_ROUTING) {
if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) { if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) {
switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'", switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'",
(long)switch_timestamp(NULL), uuid); (long)switch_epoch_time_now(NULL), uuid);
fifo_execute_sql(sql, globals.sql_mutex); fifo_execute_sql(sql, globals.sql_mutex);
} }
@ -451,7 +451,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'", switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
(long)switch_timestamp(NULL), h->uuid); (long)switch_epoch_time_now(NULL), h->uuid);
fifo_execute_sql(sql, globals.sql_mutex); fifo_execute_sql(sql, globals.sql_mutex);
goto end; goto end;
} }
@ -512,7 +512,7 @@ static void find_consumers(fifo_node_t *node)
sql = switch_mprintf("select uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, " sql = switch_mprintf("select uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, "
"next_avail, expires, static, outbound_call_count, outbound_fail_count, hostname " "next_avail, expires, static, outbound_call_count, outbound_fail_count, hostname "
"from fifo_outbound where (use_count < simo_count) and (next_avail = 0 or next_avail <= %ld) order by outbound_call_count", "from fifo_outbound where (use_count < simo_count) and (next_avail = 0 or next_avail <= %ld) order by outbound_call_count",
(long) switch_timestamp(NULL)); (long) switch_epoch_time_now(NULL));
switch_assert(sql); switch_assert(sql);
fifo_execute_sql_callback(globals.sql_mutex, sql, place_call_callback, &need); fifo_execute_sql_callback(globals.sql_mutex, sql, place_call_callback, &need);
free(sql); free(sql);
@ -668,7 +668,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_event_t *event = NULL; switch_event_t *event = NULL;
char date[80] = ""; char date[80] = "";
switch_time_exp_t tm; switch_time_exp_t tm;
switch_time_t ts = switch_timestamp_now(); switch_time_t ts = switch_micro_time_now();
switch_size_t retsize; switch_size_t retsize;
char *list_string; char *list_string;
int nlist_count; int nlist_count;
@ -796,7 +796,7 @@ SWITCH_STANDARD_APP(fifo_function)
to = 60; to = 60;
} }
} }
cd.orbit_timeout = switch_timestamp(NULL) + to; cd.orbit_timeout = switch_epoch_time_now(NULL) + to;
} }
} }
@ -823,7 +823,7 @@ SWITCH_STANDARD_APP(fifo_function)
} }
if (!node_consumer_wait_count(node)) { if (!node_consumer_wait_count(node)) {
node->start_waiting = switch_timestamp_now(); node->start_waiting = switch_micro_time_now();
} }
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
@ -843,7 +843,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_mutex_unlock(node->mutex); switch_mutex_unlock(node->mutex);
ts = switch_timestamp_now(); ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING"); switch_channel_set_variable(channel, "fifo_status", "WAITING");
@ -856,7 +856,7 @@ SWITCH_STANDARD_APP(fifo_function)
char *list_dup = switch_core_session_strdup(session, chime_list); char *list_dup = switch_core_session_strdup(session, chime_list);
cd.total = switch_separate_string(list_dup, ',', cd.list, (sizeof(cd.list) / sizeof(cd.list[0]))); cd.total = switch_separate_string(list_dup, ',', cd.list, (sizeof(cd.list) / sizeof(cd.list[0])));
cd.freq = freq; cd.freq = freq;
cd.next = switch_timestamp(NULL) + cd.freq; cd.next = switch_epoch_time_now(NULL) + cd.freq;
} }
send_presence(node); send_presence(node);
@ -930,7 +930,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_channel_set_state(channel, CS_HIBERNATE); switch_channel_set_state(channel, CS_HIBERNATE);
goto done; goto done;
} else { } else {
ts = switch_timestamp_now(); ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED"); switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED");
@ -1027,7 +1027,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_event_fire(&event); switch_event_fire(&event);
} }
ts = switch_timestamp_now(); ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING"); switch_channel_set_variable(channel, "fifo_status", "WAITING");
@ -1220,7 +1220,7 @@ SWITCH_STANDARD_APP(fifo_function)
switch_assert(cloned_profile->next == NULL); switch_assert(cloned_profile->next == NULL);
switch_channel_set_originatee_caller_profile(channel, cloned_profile); switch_channel_set_originatee_caller_profile(channel, cloned_profile);
ts = switch_timestamp_now(); ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "TALKING"); switch_channel_set_variable(channel, "fifo_status", "TALKING");
@ -1251,7 +1251,7 @@ SWITCH_STANDARD_APP(fifo_function)
} }
} }
ts = switch_timestamp_now(); ts = switch_micro_time_now();
switch_time_exp_lt(&tm, ts); switch_time_exp_lt(&tm, ts);
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
switch_channel_set_variable(channel, "fifo_status", "WAITING"); switch_channel_set_variable(channel, "fifo_status", "WAITING");
@ -1300,7 +1300,7 @@ SWITCH_STANDARD_APP(fifo_function)
} }
if (fifo_consumer_wrapup_time) { if (fifo_consumer_wrapup_time) {
wrapup_time_started = switch_timestamp_now(); wrapup_time_started = switch_micro_time_now();
} }
if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) { if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) {
@ -1308,7 +1308,7 @@ SWITCH_STANDARD_APP(fifo_function)
char terminator = 0; char terminator = 0;
if (fifo_consumer_wrapup_time) { if (fifo_consumer_wrapup_time) {
wrapup_time_elapsed = (switch_timestamp_now() - wrapup_time_started) / 1000; wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000;
if (wrapup_time_elapsed > fifo_consumer_wrapup_time) { if (wrapup_time_elapsed > fifo_consumer_wrapup_time) {
break; break;
} else { } else {
@ -1324,7 +1324,7 @@ SWITCH_STANDARD_APP(fifo_function)
} }
} else if (fifo_consumer_wrapup_time && (switch_strlen_zero(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) { } else if (fifo_consumer_wrapup_time && (switch_strlen_zero(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) {
while(switch_channel_ready(channel)) { while(switch_channel_ready(channel)) {
wrapup_time_elapsed = (switch_timestamp_now() - wrapup_time_started) / 1000; wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000;
if (wrapup_time_elapsed > fifo_consumer_wrapup_time) { if (wrapup_time_elapsed > fifo_consumer_wrapup_time) {
break; break;
} }
@ -1949,7 +1949,7 @@ SWITCH_STANDARD_API(fifo_member_api_function)
lag = atoi(argv[5]); lag = atoi(argv[5]);
} }
if (argc > 6) { if (argc > 6) {
expires = switch_timestamp(NULL) + atoi(argv[6]); expires = switch_epoch_time_now(NULL) + atoi(argv[6]);
} }
if (simo_count < 0) { if (simo_count < 0) {
simo_count = 1; simo_count = 1;

View File

@ -140,7 +140,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
vid_codec = switch_core_session_get_video_read_codec(session); vid_codec = switch_core_session_get_video_read_codec(session);
h.version = VERSION; h.version = VERSION;
h.created = switch_timestamp_now(); h.created = switch_micro_time_now();
switch_set_string(h.video_codec_name, vid_codec->implementation->iananame); switch_set_string(h.video_codec_name, vid_codec->implementation->iananame);
if (vid_codec->fmtp_in) { if (vid_codec->fmtp_in) {
switch_set_string(h.video_fmtp, vid_codec->fmtp_in); switch_set_string(h.video_fmtp, vid_codec->fmtp_in);

View File

@ -811,7 +811,7 @@ SWITCH_STANDARD_APP(limit_hash_function)
char *szinterval = NULL; char *szinterval = NULL;
limit_hash_item_t *item = NULL; limit_hash_item_t *item = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
switch_hash_t *channel_hash = NULL; switch_hash_t *channel_hash = NULL;
uint8_t increment = 1; uint8_t increment = 1;
uint8_t new_channel = 0; uint8_t new_channel = 0;

View File

@ -478,7 +478,7 @@ SWITCH_STANDARD_APP(rss_function)
switch_size_t retsize; switch_size_t retsize;
char dtmf[5] = ""; char dtmf[5] = "";
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime_nocheck(date, &retsize, sizeof(date), "%I:%M %p", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%I:%M %p", &tm);

View File

@ -1767,7 +1767,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro
} }
} }
switch_snprintf(sql, sizeof(sql), "update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and flags='save'", switch_snprintf(sql, sizeof(sql), "update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and flags='save'",
(long) switch_timestamp(NULL), myid, domain_name); (long) switch_epoch_time_now(NULL), myid, domain_name);
vm_execute_sql(profile, sql, profile->mutex); vm_execute_sql(profile, sql, profile->mutex);
switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid,
domain_name); domain_name);
@ -2309,11 +2309,11 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Flags", read_flags); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Flags", read_flags);
switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Folder", myfolder); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Folder", myfolder);
switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Message-Len", "%u", message_len); switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Message-Len", "%u", message_len);
switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Timestamp", "%lu", (unsigned long) switch_timestamp(NULL)); switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Timestamp", "%lu", (unsigned long) switch_epoch_time_now(NULL));
switch_event_fire(&message_event); switch_event_fire(&message_event);
usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_timestamp(NULL), usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_epoch_time_now(NULL),
myid, domain_name, uuid_str, caller_id_name, caller_id_number, myid, domain_name, uuid_str, caller_id_name, caller_id_number,
myfolder, file_path, message_len, read_flags); myfolder, file_path, message_len, read_flags);
@ -2346,7 +2346,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile,
&total_new_urgent_messages, &total_saved_urgent_messages); &total_new_urgent_messages, &total_saved_urgent_messages);
if (switch_strlen_zero(vm_timezone) || (switch_strftime_tz(vm_timezone, profile->date_fmt, date, sizeof(date), 0) != SWITCH_STATUS_SUCCESS)) { if (switch_strlen_zero(vm_timezone) || (switch_strftime_tz(vm_timezone, profile->date_fmt, date, sizeof(date), 0) != SWITCH_STATUS_SUCCESS)) {
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm); switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
} }
@ -2696,7 +2696,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons
switch_time_exp_t tm; switch_time_exp_t tm;
char date[80] = ""; char date[80] = "";
switch_size_t retsize; switch_size_t retsize;
switch_time_t ts = switch_timestamp_now(); switch_time_t ts = switch_micro_time_now();
char *dbuf = NULL; char *dbuf = NULL;
char *vm_storage_dir = NULL; char *vm_storage_dir = NULL;
char *record_macro = VM_RECORD_MESSAGE_MACRO; char *record_macro = VM_RECORD_MESSAGE_MACRO;
@ -3271,7 +3271,7 @@ static void do_play(vm_profile_t *profile, char *user, char *domain, char *file,
struct holder holder; struct holder holder;
sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and file_path like '%%%s'", sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and file_path like '%%%s'",
(long) switch_timestamp(NULL), user, domain, file); (long) switch_epoch_time_now(NULL), user, domain, file);
vm_execute_sql(profile, sql, profile->mutex); vm_execute_sql(profile, sql, profile->mutex);
free(sql); free(sql);

View File

@ -180,7 +180,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
assert(channel != NULL); assert(channel != NULL);
last = switch_timestamp_now() - waitsec; last = switch_micro_time_now() - waitsec;
@ -243,7 +243,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
switch_channel_mark_ring_ready(channel); switch_channel_mark_ring_ready(channel);
while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
if (switch_timestamp_now() - last >= waitsec) { if (switch_micro_time_now() - last >= waitsec) {
char buf[512]; char buf[512];
switch_event_t *event; switch_event_t *event;
@ -257,7 +257,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
last = switch_timestamp_now(); last = switch_micro_time_now();
if (ring_file) { if (ring_file) {
unsigned int pos = 0; unsigned int pos = 0;
switch_core_file_seek(&fh, &pos, 0, SEEK_SET); switch_core_file_seek(&fh, &pos, 0, SEEK_SET);

View File

@ -1070,7 +1070,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
switch_set_flag_locked(tech_pvt, TFLAG_IO); switch_set_flag_locked(tech_pvt, TFLAG_IO);
started = switch_timestamp_now(); started = switch_micro_time_now();
/* jingle has no ringing indication so we will just pretend that we got one */ /* jingle has no ringing indication so we will just pretend that we got one */
switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
@ -1088,7 +1088,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
switch_test_flag(tech_pvt, TFLAG_RTP_READY) && switch_test_flag(tech_pvt, TFLAG_RTP_READY) &&
switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) &&
tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) { tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) {
now = switch_timestamp_now(); now = switch_micro_time_now();
elapsed = (unsigned int) ((now - started) / 1000); elapsed = (unsigned int) ((now - started) / 1000);
if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) { if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) {
@ -1340,7 +1340,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
#if 0 #if 0
if (tech_pvt->last_read) { if (tech_pvt->last_read) {
elapsed = (unsigned int) ((switch_timestamp_now() - tech_pvt->last_read) / 1000); elapsed = (unsigned int) ((switch_micro_time_now() - tech_pvt->last_read) / 1000);
if (elapsed > 60000) { if (elapsed > 60000) {
return SWITCH_STATUS_TIMEOUT; return SWITCH_STATUS_TIMEOUT;
} }
@ -1368,7 +1368,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
payload = tech_pvt->read_frame.payload; payload = tech_pvt->read_frame.payload;
#if 0 #if 0
elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000); elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000);
if (timeout > -1) { if (timeout > -1) {
if (elapsed >= (unsigned int) timeout) { if (elapsed >= (unsigned int) timeout) {
@ -1376,7 +1376,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
} }
} }
elapsed = (unsigned int) ((switch_timestamp_now() - last_act) / 1000); elapsed = (unsigned int) ((switch_micro_time_now() - last_act) / 1000);
if (elapsed >= hard_timeout) { if (elapsed >= hard_timeout) {
return SWITCH_STATUS_BREAK; return SWITCH_STATUS_BREAK;
} }

View File

@ -182,7 +182,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
switch_assert(tech_pvt != NULL); switch_assert(tech_pvt != NULL);
last = switch_timestamp_now() - waitsec; last = switch_micro_time_now() - waitsec;
if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) { if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) {
hold_file = val; hold_file = val;
@ -251,7 +251,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
switch_size_t olen = globals.timer.samples; switch_size_t olen = globals.timer.samples;
if (switch_timestamp_now() - last >= waitsec) { if (switch_micro_time_now() - last >= waitsec) {
char buf[512]; char buf[512];
switch_event_t *event; switch_event_t *event;
@ -264,7 +264,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
switch_event_fire(&event); switch_event_fire(&event);
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf);
last = switch_timestamp_now(); last = switch_micro_time_now();
} }
if (ring_file) { if (ring_file) {
@ -449,7 +449,7 @@ static void remove_pvt(private_t *tech_pvt)
if (globals.call_list) { if (globals.call_list) {
switch_set_flag_locked(globals.call_list, TFLAG_MASTER); switch_set_flag_locked(globals.call_list, TFLAG_MASTER);
} else { } else {
globals.deactivate_timer = switch_timestamp(NULL) + 2; globals.deactivate_timer = switch_epoch_time_now(NULL) + 2;
deactivate_audio_device(); deactivate_audio_device();
} }
@ -1259,7 +1259,7 @@ static switch_status_t engage_device(int restart)
int codec_ms = globals.codec_ms; int codec_ms = globals.codec_ms;
switch_mutex_lock(globals.device_lock); switch_mutex_lock(globals.device_lock);
while (globals.deactivate_timer > switch_timestamp(NULL)) { while (globals.deactivate_timer > switch_epoch_time_now(NULL)) {
switch_yield(1000000); switch_yield(1000000);
} }
switch_mutex_unlock(globals.device_lock); switch_mutex_unlock(globals.device_lock);

View File

@ -1650,7 +1650,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
switch_assert(gp->state < REG_STATE_LAST); switch_assert(gp->state < REG_STATE_LAST);
stream->write_function(stream, "%25s\t%s\t %32s\t%s", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]); stream->write_function(stream, "%25s\t%s\t %32s\t%s", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
if (gp->retry > now) { if (gp->retry > now) {
stream->write_function(stream, " (retry: %ds)", gp->retry - now); stream->write_function(stream, " (retry: %ds)", gp->retry - now);
} else { } else {
@ -1842,7 +1842,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
switch_assert(gp->state < REG_STATE_LAST); switch_assert(gp->state < REG_STATE_LAST);
stream->write_function(stream, "<gateway>\n<Name>%s</Name>\n<Type>%s</Type>\n<Data>%s</Data>\n<State>%s</State>\n</gateway>\n", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]); stream->write_function(stream, "<gateway>\n<Name>%s</Name>\n<Type>%s</Type>\n<Data>%s</Data>\n<State>%s</State>\n</gateway>\n", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
if (gp->retry > now) { if (gp->retry > now) {
stream->write_function(stream, " (retry: %ds)", gp->retry - now); stream->write_function(stream, " (retry: %ds)", gp->retry - now);
} else { } else {
@ -2042,7 +2042,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) { if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) {
int rsec = 10; int rsec = 10;
int diff = (int) (switch_timestamp(NULL) - profile->started); int diff = (int) (switch_epoch_time_now(NULL) - profile->started);
int remain = rsec - diff; int remain = rsec - diff;
if (diff < rsec) { if (diff < rsec) {
stream->write_function(stream, "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n", stream->write_function(stream, "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",

View File

@ -284,11 +284,11 @@ void sofia_handle_sip_r_message(int status, sofia_profile_t *profile, nua_handle
void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout) void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout)
{ {
time_t exp = switch_timestamp(NULL) + timeout; time_t exp = switch_epoch_time_now(NULL) + timeout;
tech_pvt->want_event = event; tech_pvt->want_event = event;
while(switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_timestamp(NULL) < exp) { while(switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_epoch_time_now(NULL) < exp) {
switch_yield(100000); switch_yield(100000);
} }
@ -522,7 +522,7 @@ void event_handler(switch_event_t *event)
char *rpid = switch_event_get_header(event, "orig-rpid"); char *rpid = switch_event_get_header(event, "orig-rpid");
char *call_id = switch_event_get_header(event, "orig-call-id"); char *call_id = switch_event_get_header(event, "orig-call-id");
char *user_agent = switch_event_get_header(event, "user-agent"); char *user_agent = switch_event_get_header(event, "user-agent");
long expires = (long) switch_timestamp(NULL); long expires = (long) switch_epoch_time_now(NULL);
char *profile_name = switch_event_get_header(event, "orig-profile-name"); char *profile_name = switch_event_get_header(event, "orig-profile-name");
char *to_user = switch_event_get_header(event, "orig-to-user"); char *to_user = switch_event_get_header(event, "orig-to-user");
char *presence_hosts = switch_event_get_header(event, "presence-hosts"); char *presence_hosts = switch_event_get_header(event, "presence-hosts");
@ -601,12 +601,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread
if (++loops >= 100) { if (++loops >= 100) {
if (++ireg_loops >= IREG_SECONDS) { if (++ireg_loops >= IREG_SECONDS) {
sofia_reg_check_expire(profile, switch_timestamp(NULL), 0); sofia_reg_check_expire(profile, switch_epoch_time_now(NULL), 0);
ireg_loops = 0; ireg_loops = 0;
} }
if (++gateway_loops >= GATEWAY_SECONDS) { if (++gateway_loops >= GATEWAY_SECONDS) {
sofia_reg_check_gateway(profile, switch_timestamp(NULL)); sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL));
gateway_loops = 0; gateway_loops = 0;
} }
sofia_sub_check_gateway(profile, time(NULL)); sofia_sub_check_gateway(profile, time(NULL));
@ -778,7 +778,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name);
profile->started = switch_timestamp(NULL); profile->started = switch_epoch_time_now(NULL);
sofia_set_pflag_locked(profile, PFLAG_RUNNING); sofia_set_pflag_locked(profile, PFLAG_RUNNING);
launch_sofia_worker_thread(profile); launch_sofia_worker_thread(profile);
@ -1104,7 +1104,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
if (ping_freq) { if (ping_freq) {
if (ping_freq >= 5) { if (ping_freq >= 5) {
gateway->ping_freq = ping_freq; gateway->ping_freq = ping_freq;
gateway->ping = switch_timestamp(NULL) + ping_freq; gateway->ping = switch_epoch_time_now(NULL) + ping_freq;
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: invalid ping!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: invalid ping!\n");
} }
@ -2350,12 +2350,12 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu
gateway->state = REG_STATE_FAILED; gateway->state = REG_STATE_FAILED;
} }
} }
gateway->ping = switch_timestamp(NULL) + gateway->ping_freq; gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq;
sofia_reg_release_gateway(gateway); sofia_reg_release_gateway(gateway);
gateway->pinging = 0; gateway->pinging = 0;
} else if ((profile->pflags & PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) { } else if ((profile->pflags & PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) {
char *sql; char *sql;
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n",
sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);

View File

@ -55,7 +55,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *
} }
if (!tech_pvt->owner_id) { if (!tech_pvt->owner_id) {
tech_pvt->owner_id = (uint32_t) switch_timestamp(NULL) - port; tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port;
} }
if (!tech_pvt->session_id) { if (!tech_pvt->session_id) {
@ -145,7 +145,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
} }
if (!tech_pvt->owner_id) { if (!tech_pvt->owner_id) {
tech_pvt->owner_id = (uint32_t) switch_timestamp(NULL) - port; tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port;
} }
if (!tech_pvt->session_id) { if (!tech_pvt->session_id) {
@ -2902,7 +2902,7 @@ void sofia_glue_restart_all_profiles(void)
switch_hash_this(hi, &var, NULL, &val); switch_hash_this(hi, &var, NULL, &val);
if ((pptr = (sofia_profile_t *) val)) { if ((pptr = (sofia_profile_t *) val)) {
int rsec = 10; int rsec = 10;
int diff = (int) (switch_timestamp(NULL) - pptr->started); int diff = (int) (switch_epoch_time_now(NULL) - pptr->started);
int remain = rsec - diff; int remain = rsec - diff;
if (sofia_test_pflag(pptr, PFLAG_RESPAWN) || !sofia_test_pflag(pptr, PFLAG_RUNNING)) { if (sofia_test_pflag(pptr, PFLAG_RESPAWN) || !sofia_test_pflag(pptr, PFLAG_RUNNING)) {
continue; continue;

View File

@ -946,7 +946,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
char *open; char *open;
char *prpid; char *prpid;
const char *ct = "no/idea"; const char *ct = "no/idea";
time_t exptime = switch_timestamp(NULL) + 3600; time_t exptime = switch_epoch_time_now(NULL) + 3600;
int is_dialog = 0; int is_dialog = 0;
sofia_profile_t *ext_profile = NULL, *profile = helper->profile; sofia_profile_t *ext_profile = NULL, *profile = helper->profile;
char sstr[128] = ""; char sstr[128] = "";
@ -990,7 +990,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
if (expires) { if (expires) {
long tmp = atol(expires); long tmp = atol(expires);
if (tmp > 0) { if (tmp > 0) {
exptime = tmp - switch_timestamp(NULL) - SUB_OVERLAP; exptime = tmp - switch_epoch_time_now(NULL) - SUB_OVERLAP;
} else { } else {
exptime = tmp; exptime = tmp;
} }
@ -1281,7 +1281,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
} }
id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host); id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
expire_sec = (int) (expire_sec - switch_timestamp(NULL)); expire_sec = (int) (expire_sec - switch_epoch_time_now(NULL));
if (expire_sec < 0) { if (expire_sec < 0) {
expire_sec = 3600; expire_sec = 3600;
} }
@ -1585,7 +1585,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600); exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
if (exp_delta) { if (exp_delta) {
exp_abs = (long) switch_timestamp(NULL) + exp_delta; exp_abs = (long) switch_epoch_time_now(NULL) + exp_delta;
} else { } else {
exp_abs = 0; exp_abs = 0;
sub_state = nua_substate_terminated; sub_state = nua_substate_terminated;
@ -1859,7 +1859,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
} }
exp_delta = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600); exp_delta = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
exp = (long) switch_timestamp(NULL) + exp_delta; exp = (long) switch_epoch_time_now(NULL) + exp_delta;
if ((sql = if ((sql =
switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' " switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' "

View File

@ -612,7 +612,7 @@ void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t
switch_uuid_format(uuid_str, &uuid); switch_uuid_format(uuid_str, &uuid);
sql = switch_mprintf("insert into sip_authentication (nonce,expires,profile_name,hostname) " sql = switch_mprintf("insert into sip_authentication (nonce,expires,profile_name,hostname) "
"values('%q', %ld, '%q', '%q')", uuid_str, switch_timestamp(NULL) + profile->nonce_ttl, profile->name, mod_sofia_globals.hostname); "values('%q', %ld, '%q', '%q')", uuid_str, switch_epoch_time_now(NULL) + profile->nonce_ttl, profile->name, mod_sofia_globals.hostname);
switch_assert(sql != NULL); switch_assert(sql != NULL);
sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex);
switch_safe_free(sql); switch_safe_free(sql);
@ -940,7 +940,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
"(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname) " "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q')", "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q')",
call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host, call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host,
contact_str, reg_desc, rpid, (long) switch_timestamp(NULL) + (long) exptime * 2, contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2,
agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname); agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname);
if (sql) { if (sql) {
@ -1091,7 +1091,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
} }
} }
switch_rfc822_date(date, switch_timestamp_now()); switch_rfc822_date(date, switch_micro_time_now());
nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact), nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact),
TAG_IF(path_val, SIPTAG_PATH_STR(path_val)), TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
NUTAG_WITH_THIS(nua), NUTAG_WITH_THIS(nua),

View File

@ -99,7 +99,7 @@ static void do_rotate(cdr_fd_t *fd)
fd->fd = -1; fd->fd = -1;
if (globals.rotate) { if (globals.rotate) {
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
len = strlen(fd->path) + strlen(date) + 2; len = strlen(fd->path) + strlen(date) + 2;

View File

@ -196,7 +196,7 @@ static void event_handler(switch_event_t *event)
continue; continue;
} }
if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_timestamp(NULL) - l->last_flush > l->timeout) { if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_epoch_time_now(NULL) - l->last_flush > l->timeout) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id);
remove_listener(l); remove_listener(l);
expire_listener(&l); expire_listener(&l);

View File

@ -231,7 +231,7 @@ static void event_handler(switch_event_t *event)
continue; continue;
} }
if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_timestamp(NULL) - l->last_flush > l->timeout) { if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_epoch_time_now(NULL) - l->last_flush > l->timeout) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id);
remove_listener(l); remove_listener(l);
expire_listener(&l); expire_listener(&l);
@ -718,7 +718,7 @@ SWITCH_STANDARD_API(event_sink_function)
switch_thread_rwlock_create(&listener->rwlock, listener->pool); switch_thread_rwlock_create(&listener->rwlock, listener->pool);
listener->id = next_id(); listener->id = next_id();
listener->timeout = 60; listener->timeout = 60;
listener->last_flush = switch_timestamp(NULL); listener->last_flush = switch_epoch_time_now(NULL);
if (events) { if (events) {
char delim = ','; char delim = ',';
@ -820,7 +820,7 @@ SWITCH_STANDARD_API(event_sink_function)
goto end; goto end;
} }
listener->last_flush = switch_timestamp(NULL); listener->last_flush = switch_epoch_time_now(NULL);
stream->write_function(stream, "<data>\n <reply type=\"success\">Current Events Follow</reply>\n"); stream->write_function(stream, "<data>\n <reply type=\"success\">Current Events Follow</reply>\n");
xmlize_listener(listener, stream); xmlize_listener(listener, stream);
@ -963,7 +963,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
int clen = 0; int clen = 0;
*event = NULL; *event = NULL;
start = switch_timestamp(NULL); start = switch_epoch_time_now(NULL);
ptr = mbuf; ptr = mbuf;
@ -1074,7 +1074,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
} }
if (timeout) { if (timeout) {
elapsed = (uint32_t) (switch_timestamp(NULL) - start); elapsed = (uint32_t) (switch_epoch_time_now(NULL) - start);
if (elapsed >= timeout) { if (elapsed >= timeout) {
switch_clear_flag_locked(listener, LFLAG_RUNNING); switch_clear_flag_locked(listener, LFLAG_RUNNING);
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;

View File

@ -2118,7 +2118,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
channel = switch_core_session_get_channel(jss->session); channel = switch_core_session_get_channel(jss->session);
CHANNEL_MEDIA_SANITY_CHECK(); CHANNEL_MEDIA_SANITY_CHECK();
started = switch_timestamp_now(); started = switch_micro_time_now();
if (argc > 0) { if (argc > 0) {
JS_ValueToInt32(cx, argv[0], &timeout); JS_ValueToInt32(cx, argv[0], &timeout);
@ -2132,7 +2132,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc,
} }
saveDepth = JS_SuspendRequest(cx); saveDepth = JS_SuspendRequest(cx);
for (;;) { for (;;) {
if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) if (((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > (switch_time_t) timeout)
|| switch_channel_get_state(channel) >= CS_HANGUP) { || switch_channel_get_state(channel) >= CS_HANGUP) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
break; break;
@ -2165,7 +2165,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
METHOD_SANITY_CHECK(); METHOD_SANITY_CHECK();
channel = switch_core_session_get_channel(jss->session); channel = switch_core_session_get_channel(jss->session);
started = switch_timestamp_now(); started = switch_micro_time_now();
if (argc > 0) { if (argc > 0) {
JS_ValueToInt32(cx, argv[0], &timeout); JS_ValueToInt32(cx, argv[0], &timeout);
@ -2180,7 +2180,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc
saveDepth = JS_SuspendRequest(cx); saveDepth = JS_SuspendRequest(cx);
for (;;) { for (;;) {
if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) if (((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > (switch_time_t) timeout)
|| switch_channel_get_state(channel) >= CS_HANGUP) { || switch_channel_get_state(channel) >= CS_HANGUP) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
break; break;

View File

@ -124,7 +124,7 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile)
switch_mutex_lock(globals.mutex); switch_mutex_lock(globals.mutex);
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);
profile->log_size = 0; profile->log_size = 0;

View File

@ -303,7 +303,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -361,7 +361,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
if ((t = atoi(tosay)) > 0) { if ((t = atoi(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);

View File

@ -294,7 +294,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atol(tosay)) <= 0) { if ((seconds = atol(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -352,7 +352,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
if ((t = atol(tosay)) > 0) { if ((t = atol(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
if (tz) { if (tz) {

View File

@ -292,7 +292,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -350,7 +350,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
if ((t = atoi(tosay)) > 0) { if ((t = atoi(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);

View File

@ -292,7 +292,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -350,7 +350,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay,
if ((t = atoi(tosay)) > 0) { if ((t = atoi(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);

View File

@ -292,7 +292,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -350,7 +350,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
if ((t = atoi(tosay)) > 0) { if ((t = atoi(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);

View File

@ -292,7 +292,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -350,7 +350,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
if ((t = atoi(tosay)) > 0) { if ((t = atoi(tosay)) > 0) {
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
} else { } else {
target = switch_timestamp_now(); target = switch_micro_time_now();
} }
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);

View File

@ -367,7 +367,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
} }
} else { } else {
if ((seconds = atoi(tosay)) <= 0) { if ((seconds = atoi(tosay)) <= 0) {
seconds = (int64_t) switch_timestamp(NULL); seconds = (int64_t) switch_epoch_time_now(NULL);
} }
if (seconds >= 60) { if (seconds >= 60) {
@ -425,7 +425,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
if ((t = atoi(tosay)) > 0) if ((t = atoi(tosay)) > 0)
target = switch_time_make(t, 0); target = switch_time_make(t, 0);
else else
target = switch_timestamp_now(); target = switch_micro_time_now();
switch_time_exp_lt(&tm, target); switch_time_exp_lt(&tm, target);
switch (type) { switch (type) {
@ -455,7 +455,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
#if 0 #if 0
tm = *localtime(&then); tm = *localtime(&then);
this_morning = switch_timestamp_now(); this_morning = switch_micro_time_now();
switch_time_exp_lt(&tm2, this_morning); switch_time_exp_lt(&tm2, this_morning);
tm2->tm_hour = 0; tm2->tm_hour = 0;
tm2->tm_min = 0; tm2->tm_min = 0;

View File

@ -1328,7 +1328,7 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel
} }
caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times)); caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
caller_profile->times->profile_created = switch_timestamp_now(); caller_profile->times->profile_created = switch_micro_time_now();
if (channel->caller_profile && channel->caller_profile->times) { if (channel->caller_profile && channel->caller_profile->times) {
channel->caller_profile->times->transferred = caller_profile->times->profile_created; channel->caller_profile->times->transferred = caller_profile->times->profile_created;
@ -1341,7 +1341,7 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel
switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool); switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool);
} }
} else { } else {
caller_profile->times->created = switch_timestamp_now(); caller_profile->times->created = switch_micro_time_now();
} }
caller_profile->next = channel->caller_profile; caller_profile->next = channel->caller_profile;
@ -1534,7 +1534,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->hungup = switch_timestamp_now(); channel->caller_profile->times->hungup = switch_micro_time_now();
switch_mutex_unlock(channel->profile_mutex); switch_mutex_unlock(channel->profile_mutex);
} }
@ -1580,7 +1580,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
switch_channel_set_flag(channel, CF_RING_READY); switch_channel_set_flag(channel, CF_RING_READY);
if (channel->caller_profile && channel->caller_profile->times) { if (channel->caller_profile && channel->caller_profile->times) {
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->progress = switch_timestamp_now(); channel->caller_profile->times->progress = switch_micro_time_now();
if (channel->caller_profile->originator_caller_profile) { if (channel->caller_profile->originator_caller_profile) {
switch_core_session_t *other_session; switch_core_session_t *other_session;
if ((other_session = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) { if ((other_session = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) {
@ -1638,7 +1638,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
if (channel->caller_profile && channel->caller_profile->times) { if (channel->caller_profile && channel->caller_profile->times) {
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->progress_media = switch_timestamp_now(); channel->caller_profile->times->progress_media = switch_micro_time_now();
if (channel->caller_profile->originator_caller_profile) { if (channel->caller_profile->originator_caller_profile) {
switch_core_session_t *osession; switch_core_session_t *osession;
if ((osession = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) { if ((osession = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) {
@ -1756,7 +1756,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
if (channel->caller_profile && channel->caller_profile->times) { if (channel->caller_profile && channel->caller_profile->times) {
switch_mutex_lock(channel->profile_mutex); switch_mutex_lock(channel->profile_mutex);
channel->caller_profile->times->answered = switch_timestamp_now(); channel->caller_profile->times->answered = switch_micro_time_now();
switch_mutex_unlock(channel->profile_mutex); switch_mutex_unlock(channel->profile_mutex);
} }

View File

@ -296,7 +296,7 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const
goto done; goto done;
} }
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
if (channel == SWITCH_CHANNEL_ID_LOG) { if (channel == SWITCH_CHANNEL_ID_LOG) {

View File

@ -136,7 +136,7 @@ SWITCH_STANDARD_SCHED_FUNC(heartbeat_callback)
check_ip(); check_ip();
/* reschedule this task */ /* reschedule this task */
task->runtime = switch_timestamp(NULL) + 20; task->runtime = switch_epoch_time_now(NULL) + 20;
} }
@ -1088,7 +1088,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
switch_scheduler_task_thread_start(); switch_scheduler_task_thread_start();
runtime.initiated = switch_time_now(); runtime.initiated = switch_time_now();
switch_scheduler_add_task(switch_timestamp(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL); switch_scheduler_add_task(switch_epoch_time_now(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL);
switch_uuid_get(&uuid); switch_uuid_get(&uuid);
switch_uuid_format(runtime.uuid_str, &uuid); switch_uuid_format(runtime.uuid_str, &uuid);
@ -1323,7 +1323,7 @@ SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_cor
SWITCH_DECLARE(switch_time_t) switch_core_uptime(void) SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
{ {
return switch_timestamp_now() - runtime.initiated; return switch_micro_time_now() - runtime.initiated;
} }
SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val) SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val)

View File

@ -353,7 +353,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
} }
} }
if (bp->stop_time && bp->stop_time <= switch_timestamp(NULL)) { if (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) {
ok = SWITCH_FALSE; ok = SWITCH_FALSE;
} }
@ -502,7 +502,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
switch_mutex_lock(bp->read_mutex); switch_mutex_lock(bp->read_mutex);
if (bp->callback) { if (bp->callback) {
if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE
|| (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) { || (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) {
ok = SWITCH_FALSE; ok = SWITCH_FALSE;
} }
} }
@ -775,7 +775,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
} }
} }
if (bp->stop_time && bp->stop_time <= switch_timestamp(NULL)) { if (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) {
ok = SWITCH_FALSE; ok = SWITCH_FALSE;
} }

View File

@ -118,7 +118,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c
int odd = switch_test_flag(alloc, SPF_ODD); int odd = switch_test_flag(alloc, SPF_ODD);
switch_mutex_lock(alloc->mutex); switch_mutex_lock(alloc->mutex);
srand(getpid() + (unsigned) switch_timestamp(NULL)); srand(getpid() + (unsigned) switch_epoch_time_now(NULL));
while (alloc->track_used < alloc->track_len) { while (alloc->track_used < alloc->track_len) {
uint32_t index; uint32_t index;

View File

@ -874,7 +874,7 @@ SWITCH_STANDARD_SCHED_FUNC(sch_heartbeat_callback)
switch_event_fire(&event); switch_event_fire(&event);
/* reschedule this task */ /* reschedule this task */
task->runtime = switch_timestamp(NULL) + session->track_duration; task->runtime = switch_epoch_time_now(NULL) + session->track_duration;
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
} }
@ -892,7 +892,7 @@ SWITCH_DECLARE(void) switch_core_session_sched_heartbeat(switch_core_session_t *
{ {
switch_core_session_unsched_heartbeat(session); switch_core_session_unsched_heartbeat(session);
session->track_id = switch_scheduler_add_task(switch_timestamp(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__, session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__,
switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG); switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG);
} }

View File

@ -278,7 +278,7 @@ static void core_event_handler(switch_event_t *event)
sql = switch_mprintf("insert into channels (uuid,created,created_epoch, name,state,dialplan,context) values('%q','%q','%ld','%q','%q','%q','%q')", sql = switch_mprintf("insert into channels (uuid,created,created_epoch, name,state,dialplan,context) values('%q','%q','%ld','%q','%q','%q','%q')",
switch_event_get_header_nil(event, "unique-id"), switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "event-date-local"), switch_event_get_header_nil(event, "event-date-local"),
(long)switch_timestamp(NULL), (long)switch_epoch_time_now(NULL),
switch_event_get_header_nil(event, "channel-name"), switch_event_get_header_nil(event, "channel-name"),
switch_event_get_header_nil(event, "channel-state"), switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "caller-dialplan"), switch_event_get_header_nil(event, "caller-dialplan"),
@ -339,7 +339,7 @@ static void core_event_handler(switch_event_t *event)
case SWITCH_EVENT_CHANNEL_BRIDGE: case SWITCH_EVENT_CHANNEL_BRIDGE:
sql = switch_mprintf("insert into calls values ('%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s')", sql = switch_mprintf("insert into calls values ('%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s')",
switch_event_get_header_nil(event, "event-date-local"), switch_event_get_header_nil(event, "event-date-local"),
(long)switch_timestamp(NULL), (long)switch_epoch_time_now(NULL),
switch_event_get_header_nil(event, "event-calling-function"), switch_event_get_header_nil(event, "event-calling-function"),
switch_event_get_header_nil(event, "caller-caller-id-name"), switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"), switch_event_get_header_nil(event, "caller-caller-id-number"),

View File

@ -1019,7 +1019,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con
switch_time_exp_t tm; switch_time_exp_t tm;
char date[80] = ""; char date[80] = "";
switch_size_t retsize; switch_size_t retsize;
switch_time_t ts = switch_timestamp_now(); switch_time_t ts = switch_micro_time_now();
switch_assert(BLOCK != NULL); switch_assert(BLOCK != NULL);
switch_assert(RUNTIME_POOL != NULL); switch_assert(RUNTIME_POOL != NULL);

View File

@ -42,7 +42,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_time_t start = switch_timestamp_now(), now, done = switch_timestamp_now() + (ms * 1000); switch_time_t start = switch_micro_time_now(), now, done = switch_micro_time_now() + (ms * 1000);
switch_frame_t *read_frame, cng_frame = { 0 }; switch_frame_t *read_frame, cng_frame = { 0 };
int32_t left, elapsed; int32_t left, elapsed;
char data[2] = ""; char data[2] = "";
@ -114,7 +114,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
} }
for (;;) { for (;;) {
now = switch_timestamp_now(); now = switch_micro_time_now();
elapsed = (int32_t) ((now - start) / 1000); elapsed = (int32_t) ((now - start) / 1000);
left = ms - elapsed; left = ms - elapsed;
@ -452,9 +452,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
switch_channel_get_name(channel), app_name, switch_str_nil(app_arg)); switch_channel_get_name(channel), app_name, switch_str_nil(app_arg));
b4 = switch_timestamp_now(); b4 = switch_micro_time_now();
switch_core_session_exec(session, application_interface, app_arg); switch_core_session_exec(session, application_interface, app_arg);
aftr = switch_timestamp_now(); aftr = switch_micro_time_now();
if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) { if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) {
break; break;
} }
@ -593,7 +593,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
if ((timeout = atoi(to)) < 0) { if ((timeout = atoi(to)) < 0) {
timeout = 0; timeout = 0;
} else { } else {
expires = switch_timestamp(NULL) + timeout; expires = switch_epoch_time_now(NULL) + timeout;
} }
} }
@ -610,7 +610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
break; break;
} }
if (expires && switch_timestamp(NULL) >= expires) { if (expires && switch_epoch_time_now(NULL) >= expires) {
switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE); switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
break; break;
} }
@ -733,7 +733,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
} }
if (timeout) { if (timeout) {
started = switch_timestamp_now(); started = switch_micro_time_now();
} }
while (switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
@ -748,7 +748,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
} }
if (timeout) { if (timeout) {
elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000); elapsed = (uint32_t) ((switch_micro_time_now() - started) / 1000);
if (elapsed >= timeout) { if (elapsed >= timeout) {
break; break;
} }
@ -855,7 +855,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
} }
if (abs_timeout) { if (abs_timeout) {
started = switch_timestamp_now(); started = switch_micro_time_now();
} }
if (digit_timeout && first_timeout) { if (digit_timeout && first_timeout) {
@ -868,14 +868,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
if (eff_timeout) { if (eff_timeout) {
digit_started = switch_timestamp_now(); digit_started = switch_micro_time_now();
} }
while (switch_channel_ready(channel)) { while (switch_channel_ready(channel)) {
switch_frame_t *read_frame; switch_frame_t *read_frame;
if (abs_timeout) { if (abs_timeout) {
abs_elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000); abs_elapsed = (uint32_t) ((switch_micro_time_now() - started) / 1000);
if (abs_elapsed >= abs_timeout) { if (abs_elapsed >= abs_timeout) {
break; break;
} }
@ -887,7 +887,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
if (eff_timeout) { if (eff_timeout) {
digit_elapsed = (uint32_t) ((switch_timestamp_now() - digit_started) / 1000); digit_elapsed = (uint32_t) ((switch_micro_time_now() - digit_started) / 1000);
if (digit_elapsed >= eff_timeout) { if (digit_elapsed >= eff_timeout) {
status = SWITCH_STATUS_TIMEOUT; status = SWITCH_STATUS_TIMEOUT;
break; break;
@ -900,7 +900,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
if (eff_timeout) { if (eff_timeout) {
eff_timeout = digit_timeout; eff_timeout = digit_timeout;
digit_started = switch_timestamp_now(); digit_started = switch_micro_time_now();
} }
for (y = 0; y <= maxdigits; y++) { for (y = 0; y <= maxdigits; y++) {
@ -1476,12 +1476,12 @@ SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stre
stream->digits = tmp; stream->digits = tmp;
*(stream->digits + (len++)) = digit; *(stream->digits + (len++)) = digit;
*(stream->digits + len) = '\0'; *(stream->digits + len) = '\0';
stream->last_digit_time = switch_timestamp_now() / 1000; stream->last_digit_time = switch_micro_time_now() / 1000;
} }
} }
} }
/* don't allow collected digit string testing if there are varying sized keys until timeout */ /* don't allow collected digit string testing if there are varying sized keys until timeout */
if (parser->maxlen - parser->minlen > 0 && (switch_timestamp_now() / 1000) - stream->last_digit_time < parser->digit_timeout_ms) { if (parser->maxlen - parser->minlen > 0 && (switch_micro_time_now() / 1000) - stream->last_digit_time < parser->digit_timeout_ms) {
len = 0; len = 0;
} }
/* if we have digits to test */ /* if we have digits to test */

View File

@ -378,7 +378,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
switch_channel_pre_answer(channel); switch_channel_pre_answer(channel);
if (limit) { if (limit) {
to = switch_timestamp(NULL) + limit; to = switch_epoch_time_now(NULL) + limit;
} }
if (flags && strchr(flags, 'm')) { if (flags && strchr(flags, 'm')) {
@ -892,7 +892,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t
} }
if (limit) { if (limit) {
to = switch_timestamp(NULL) + limit; to = switch_epoch_time_now(NULL) + limit;
} }
if ((status = switch_core_media_bug_add(session, record_callback, fh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) { if ((status = switch_core_media_bug_add(session, record_callback, fh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
@ -1525,7 +1525,7 @@ static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY); dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY);
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
char digit[2] = ""; char digit[2] = "";
int dval; int dval;

View File

@ -219,7 +219,7 @@ static int check_per_channel_timeouts(originate_status_t *originate_status,
time_t start) time_t start)
{ {
int x = 0,i; int x = 0,i;
time_t elapsed = switch_timestamp(NULL) - start; time_t elapsed = switch_epoch_time_now(NULL) - start;
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
if (originate_status[i].peer_channel && switch_channel_get_state(originate_status[i].peer_channel) < CS_HANGUP) { if (originate_status[i].peer_channel && switch_channel_get_state(originate_status[i].peer_channel) < CS_HANGUP) {
@ -592,7 +592,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
} }
timelimit *= 1000000; timelimit *= 1000000;
start = switch_timestamp_now(); start = switch_micro_time_now();
if (caller_channel) { if (caller_channel) {
if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) { if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
@ -708,7 +708,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
while (switch_channel_ready(peer_channel) while (switch_channel_ready(peer_channel)
&& !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) { && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
int diff = (int) (switch_timestamp_now() - start); int diff = (int) (switch_micro_time_now() - start);
if (diff > timelimit) { if (diff > timelimit) {
status = SWITCH_STATUS_TIMEOUT; status = SWITCH_STATUS_TIMEOUT;
@ -1486,7 +1486,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
} }
switch_timestamp(&start); switch_epoch_time_now(&start);
for (;;) { for (;;) {
uint32_t valid_channels = 0; uint32_t valid_channels = 0;
@ -1514,7 +1514,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
goto notready; goto notready;
} }
elapsed = switch_timestamp(NULL) - start; elapsed = switch_epoch_time_now(NULL) - start;
if (elapsed > (time_t) timelimit_sec) { if (elapsed > (time_t) timelimit_sec) {
to++; to++;
@ -1653,7 +1653,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) { while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) {
time_t elapsed = switch_timestamp(NULL) - start; time_t elapsed = switch_epoch_time_now(NULL) - start;
if (caller_channel && !oglobals.sent_ring && oglobals.ring_ready && !oglobals.return_ring_ready) { if (caller_channel && !oglobals.sent_ring && oglobals.ring_ready && !oglobals.return_ring_ready) {
switch_channel_ring_ready(caller_channel); switch_channel_ring_ready(caller_channel);
oglobals.sent_ring = 1; oglobals.sent_ring = 1;

View File

@ -497,7 +497,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
} }
if (limit) { if (limit) {
start = switch_timestamp(NULL); start = switch_epoch_time_now(NULL);
} }
if (fh->thresh) { if (fh->thresh) {
@ -531,7 +531,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
switch_ivr_parse_all_events(session); switch_ivr_parse_all_events(session);
} }
if (start && (switch_timestamp(NULL) - start) > limit) { if (start && (switch_epoch_time_now(NULL) - start) > limit) {
break; break;
} }

View File

@ -246,7 +246,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char
const char *filep = (file ? switch_cut_path(file) : ""); const char *filep = (file ? switch_cut_path(file) : "");
const char *funcp = (func ? func : ""); const char *funcp = (func ? func : "");
char *content = NULL; char *content = NULL;
switch_time_t now = switch_timestamp_now(); switch_time_t now = switch_micro_time_now();
uint32_t len; uint32_t len;
const char *extra_fmt = "%s [%s] %s:%d %s()%c%s"; const char *extra_fmt = "%s [%s] %s:%d %s()%c%s";

View File

@ -206,7 +206,7 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples
int16_t x; int16_t x;
uint32_t i; uint32_t i;
int sum_rnd = 0; int sum_rnd = 0;
int16_t rnd2 = (int16_t) switch_timestamp_now(); int16_t rnd2 = (int16_t) switch_micro_time_now();
assert(divisor); assert(divisor);

View File

@ -228,7 +228,7 @@ static switch_status_t do_stun_ping(switch_rtp_t *rtp_session)
#if 0 #if 0
if (rtp_session->last_stun) { if (rtp_session->last_stun) {
elapsed = (unsigned int) ((switch_timestamp_now() - rtp_session->last_stun) / 1000); elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session->last_stun) / 1000);
if (elapsed > 30000) { if (elapsed > 30000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n");
@ -282,7 +282,7 @@ static switch_status_t ice_out(switch_rtp_t *rtp_session)
} }
if (rtp_session->last_stun) { if (rtp_session->last_stun) {
elapsed = (unsigned int) ((switch_timestamp_now() - rtp_session->last_stun) / 1000); elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session->last_stun) / 1000);
if (elapsed > 30000) { if (elapsed > 30000) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n");
@ -310,7 +310,7 @@ static void handle_stun_ping_reply(switch_rtp_t *rtp_session, void *data, switch
return; return;
} }
rtp_session->last_stun = switch_timestamp_now(); rtp_session->last_stun = switch_micro_time_now();
} }
static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len) static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len)
@ -346,7 +346,7 @@ static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len)
} }
end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf)); end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf));
rtp_session->last_stun = switch_timestamp_now(); rtp_session->last_stun = switch_micro_time_now();
switch_stun_packet_first_attribute(packet, attr); switch_stun_packet_first_attribute(packet, attr);
@ -830,7 +830,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
rtp_session->seq = (uint16_t) rand(); rtp_session->seq = (uint16_t) rand();
rtp_session->ssrc = (uint32_t) ((intptr_t) &rtp_session + (uint32_t) switch_timestamp(NULL)); rtp_session->ssrc = (uint32_t) ((intptr_t) &rtp_session + (uint32_t) switch_epoch_time_now(NULL));
rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc); rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc);
rtp_session->send_msg.header.ts = 0; rtp_session->send_msg.header.ts = 0;
rtp_session->send_msg.header.m = 0; rtp_session->send_msg.header.m = 0;
@ -1967,7 +1967,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
} }
if (!rtp_session->timer.interval && if (!rtp_session->timer.interval &&
((unsigned)((switch_timestamp_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet *2)) { ((unsigned)((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet *2)) {
m++; m++;
} }
@ -1995,7 +1995,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
uint32_t rate = 0; uint32_t rate = 0;
uint32_t codec_flags = 0; uint32_t codec_flags = 0;
uint32_t len = sizeof(decoded); uint32_t len = sizeof(decoded);
time_t now = switch_timestamp(NULL); time_t now = switch_epoch_time_now(NULL);
send = 0; send = 0;
if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) { if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) {
@ -2132,7 +2132,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
if (rtp_session->timer.interval) { if (rtp_session->timer.interval) {
rtp_session->last_write_samplecount = rtp_session->timer.samplecount; rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
} else { } else {
rtp_session->last_write_timestamp = (uint32_t) switch_timestamp_now(); rtp_session->last_write_timestamp = (uint32_t) switch_micro_time_now();
} }
rtp_session->last_write_ts = this_ts; rtp_session->last_write_ts = this_ts;
@ -2209,7 +2209,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session,
rtp_session->vad_data.cng_freq = 50; rtp_session->vad_data.cng_freq = 50;
rtp_session->vad_data.ts = 1; rtp_session->vad_data.ts = 1;
rtp_session->vad_data.start = 0; rtp_session->vad_data.start = 0;
rtp_session->vad_data.next_scan = switch_timestamp(NULL); rtp_session->vad_data.next_scan = switch_epoch_time_now(NULL);
rtp_session->vad_data.scan_freq = 0; rtp_session->vad_data.scan_freq = 0;
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD); switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD);
switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG); switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG);

View File

@ -107,7 +107,7 @@ static int task_thread_loop(int done)
if (done) { if (done) {
tp->destroyed = 1; tp->destroyed = 1;
} else { } else {
int64_t now = switch_timestamp(NULL); int64_t now = switch_epoch_time_now(NULL);
if (now >= tp->task.runtime && !tp->in_thread) { if (now >= tp->task.runtime && !tp->in_thread) {
int32_t diff = (int32_t) (now - tp->task.runtime); int32_t diff = (int32_t) (now - tp->task.runtime);
if (diff > 1) { if (diff > 1) {
@ -190,7 +190,7 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
switch_zmalloc(container, sizeof(*container)); switch_zmalloc(container, sizeof(*container));
switch_assert(func); switch_assert(func);
container->func = func; container->func = func;
container->task.created = switch_timestamp(NULL); container->task.created = switch_epoch_time_now(NULL);
container->task.runtime = task_runtime; container->task.runtime = task_runtime;
container->task.group = strdup(group ? group : "none"); container->task.group = strdup(group ? group : "none");
container->task.cmd_id = cmd_id; container->task.cmd_id = cmd_id;

View File

@ -105,7 +105,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se
max = (int) strlen(set); max = (int) strlen(set);
srand((unsigned int) switch_timestamp_now()); srand((unsigned int) switch_micro_time_now());
for (x = 0; x < len; x++) { for (x = 0; x < len; x++) {
int j = (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)); int j = (int) (max * 1.0 * rand() / (RAND_MAX + 1.0));
@ -510,7 +510,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
} }
switch_socket_sendto(sock, remote_addr, 0, (void *) packet, &bytes); switch_socket_sendto(sock, remote_addr, 0, (void *) packet, &bytes);
started = switch_timestamp_now(); started = switch_micro_time_now();
*ip = NULL; *ip = NULL;
*port = 0; *port = 0;
@ -522,7 +522,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
break; break;
} }
if ((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > 5000) { if ((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > 5000) {
*err = "Timeout"; *err = "Timeout";
switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE); switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE);
switch_socket_close(sock); switch_socket_close(sock);

View File

@ -111,15 +111,15 @@ static void do_sleep(switch_interval_time_t t)
} }
SWITCH_DECLARE(switch_time_t) switch_timestamp_now(void) SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void)
{ {
return runtime.timestamp ? runtime.timestamp : switch_time_now(); return runtime.timestamp ? runtime.timestamp : switch_time_now();
} }
SWITCH_DECLARE(time_t) switch_timestamp(time_t *t) SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t)
{ {
time_t now = switch_timestamp_now() / APR_USEC_PER_SEC; time_t now = switch_micro_time_now() / APR_USEC_PER_SEC;
if (t) { if (t) {
*t = now; *t = now;
} }
@ -671,7 +671,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_t
time_t timep; time_t timep;
if (!thetime) { if (!thetime) {
thetime = switch_timestamp_now(); thetime = switch_micro_time_now();
} }
timep = (thetime) / (int64_t) (1000000); timep = (thetime) / (int64_t) (1000000);
@ -707,7 +707,7 @@ SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *f
switch_time_exp_t stm; switch_time_exp_t stm;
if (!thetime) { if (!thetime) {
thetime = switch_timestamp_now(); thetime = switch_micro_time_now();
} }
timep = (thetime) / (int64_t) (1000000); timep = (thetime) / (int64_t) (1000000);

View File

@ -377,7 +377,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr
unsigned char in[B64BUFFLEN]; unsigned char in[B64BUFFLEN];
unsigned char out[B64BUFFLEN + 512]; unsigned char out[B64BUFFLEN + 512];
switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_timestamp(NULL), rand() & 0xffff); switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_epoch_time_now(NULL), rand() & 0xffff);
if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) { if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) {
if (file) { if (file) {
@ -828,7 +828,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in)
switch_time_t ret = 0; switch_time_t ret = 0;
char *pattern = "^(\\d+)-(\\d+)-(\\d+)\\s*(\\d*):{0,1}(\\d*):{0,1}(\\d*)"; char *pattern = "^(\\d+)-(\\d+)-(\\d+)\\s*(\\d*):{0,1}(\\d*):{0,1}(\\d*)";
switch_time_exp_lt(&tm, switch_timestamp_now()); switch_time_exp_lt(&tm, switch_micro_time_now());
tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
if ((proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { if ((proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {