change a few things to allow timers to generate timestamps

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4452 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-03-05 20:53:54 +00:00
parent 8669a459fe
commit 1b5fe10277
10 changed files with 89 additions and 32 deletions
@@ -1619,6 +1619,7 @@ static void conference_loop_output(conference_member_t *member)
if (member->volume_out_level) {
switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
}
write_frame.timestamp = timer.samplecount;
switch_core_session_write_frame(member->session, &write_frame, -1, 0);
/* forget the conference data we played file node data instead */
@@ -1648,6 +1649,7 @@ static void conference_loop_output(conference_member_t *member)
switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
}
write_frame.timestamp = timer.samplecount;
switch_core_session_write_frame(member->session, &write_frame, -1, 0);
}
}
@@ -147,7 +147,7 @@ struct private_object {
unsigned int cand_id;
unsigned int desc_id;
unsigned int dc;
int32_t timestamp_send;
switch_size_t timestamp_send;
int32_t timestamp_recv;
uint32_t last_read;
char *codec_name;
@@ -1356,12 +1356,12 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
}
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, samples) < 0) {
tech_pvt->timestamp_send += samples;
if (switch_rtp_write_frame(tech_pvt->rtp_session, frame, (uint32_t)tech_pvt->timestamp_send) < 0) {
terminate_session(&session, __LINE__, SWITCH_CAUSE_NORMAL_CLEARING);
return SWITCH_STATUS_FALSE;
}
tech_pvt->timestamp_send += (int) samples;
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
+5 -5
View File
@@ -276,7 +276,7 @@ struct private_object {
switch_codec_t write_codec;
uint32_t codec_ms;
switch_caller_profile_t *caller_profile;
int32_t timestamp_send;
switch_size_t timestamp_send;
//int32_t timestamp_recv;
switch_rtp_t *rtp_session;
int ssrc;
@@ -682,7 +682,6 @@ static char *find_reg_url(sofia_profile_t *profile, const char *user, const char
if (cbt.matches) {
return val;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", user, host);
return NULL;
}
}
@@ -1881,9 +1880,8 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
tech_pvt->timestamp_send);
#endif
switch_rtp_write_frame(tech_pvt->rtp_session, frame, samples);
tech_pvt->timestamp_send += (int) samples;
tech_pvt->timestamp_send += samples;
switch_rtp_write_frame(tech_pvt->rtp_session, frame, (uint32_t)tech_pvt->timestamp_send);
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
return status;
@@ -2300,6 +2298,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
tech_pvt->dest = switch_core_session_strdup(nsession, buf);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, host);
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
terminate_session(&nsession, cause, __LINE__);
goto done;
@@ -2311,6 +2310,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
tech_pvt->dest = switch_core_session_strdup(nsession, buf);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate registered user %s@%s\n", dest, profile_name);
cause = SWITCH_CAUSE_NO_ROUTE_DESTINATION;
terminate_session(&nsession, cause, __LINE__);
goto done;
+9 -7
View File
@@ -43,12 +43,12 @@ static const char modname[] = "mod_softtimer";
#define MAX_ELEMENTS 1000
struct timer_private {
uint64_t reference;
switch_size_t reference;
};
typedef struct timer_private timer_private_t;
struct timer_matrix {
uint64_t tick;
switch_size_t tick;
uint32_t count;
};
typedef struct timer_matrix timer_matrix_t;
@@ -86,7 +86,9 @@ static inline switch_status_t timer_step(switch_timer_t *timer)
return SWITCH_STATUS_FALSE;
}
private_info->reference += timer->interval;
timer->samplecount = timer->samples * private_info->reference;
private_info->reference++;// timer->interval;
return SWITCH_STATUS_SUCCESS;
}
@@ -101,8 +103,7 @@ static inline switch_status_t timer_next(switch_timer_t *timer)
switch_yield(1000);
}
if (globals.RUNNING == 1) {
timer->samplecount += timer->samples;
if (globals.RUNNING == 1) {
return SWITCH_STATUS_SUCCESS;
}
@@ -114,7 +115,7 @@ static inline switch_status_t timer_check(switch_timer_t *timer)
{
timer_private_t *private_info = timer->private_info;
switch_status_t status = SWITCH_STATUS_SUCCESS;
uint64_t diff;
switch_size_t diff;
if (globals.RUNNING != 1) {
return SWITCH_STATUS_SUCCESS;
@@ -210,7 +211,8 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
index = (current_ms % i == 0) ? i : 0;
if (TIMER_MATRIX[index].count) {
TIMER_MATRIX[index].tick += index;
//TIMER_MATRIX[index].tick += index;
TIMER_MATRIX[index].tick++;
}
}