mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 04:27:25 +00:00
mod_sangoma_codec: more timing debug code
This commit is contained in:
parent
6e06ba09eb
commit
cd124ad802
@ -137,6 +137,7 @@ struct codec_data {
|
|||||||
/* avg Rx time */
|
/* avg Rx time */
|
||||||
switch_time_t avgrxus;
|
switch_time_t avgrxus;
|
||||||
switch_time_t last_rx_time;
|
switch_time_t last_rx_time;
|
||||||
|
switch_time_t last_func_call_time;
|
||||||
|
|
||||||
/* RTP queue. The bigger the queue, the bigger the possible delay */
|
/* RTP queue. The bigger the queue, the bigger the possible delay */
|
||||||
struct sangoma_rtp_payload rtp_queue[SANGOMA_RTP_QUEUE_SIZE];
|
struct sangoma_rtp_payload rtp_queue[SANGOMA_RTP_QUEUE_SIZE];
|
||||||
@ -386,7 +387,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
|
|||||||
switch_frame_t encoded_frame;
|
switch_frame_t encoded_frame;
|
||||||
switch_status_t sres;
|
switch_status_t sres;
|
||||||
switch_time_t now_time, difftime;
|
switch_time_t now_time, difftime;
|
||||||
switch_time_t prevread_time, afterread_time;
|
switch_time_t func_start_time, func_end_time;
|
||||||
unsigned char ebuf_ulaw[decoded_data_len / 2];
|
unsigned char ebuf_ulaw[decoded_data_len / 2];
|
||||||
short *dbuf_linear;
|
short *dbuf_linear;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -394,7 +395,7 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
|
|||||||
struct sangoma_transcoding_session *sess = codec->private_info;
|
struct sangoma_transcoding_session *sess = codec->private_info;
|
||||||
|
|
||||||
if (sess->encoder.debug_timing) {
|
if (sess->encoder.debug_timing) {
|
||||||
prevread_time = switch_micro_time_now();
|
func_start_time = switch_micro_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start assuming we will not encode anything */
|
/* start assuming we will not encode anything */
|
||||||
@ -416,13 +417,10 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
|
|||||||
switch_mutex_unlock(g_sessions_lock);
|
switch_mutex_unlock(g_sessions_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sess->encoder.debug_timing) {
|
if (sess->encoder.debug_timing && sess->encoder.last_func_call_time) {
|
||||||
now_time = switch_micro_time_now();
|
difftime = func_start_time - sess->encoder.last_func_call_time;
|
||||||
if (sess->encoder.last_rx_time) {
|
|
||||||
difftime = now_time - sess->encoder.last_rx_time;
|
|
||||||
if (difftime > 25000 || difftime < 15000) {
|
if (difftime > 25000 || difftime < 15000) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%ldus since last read on encoding session %lu.\n", (long)difftime, sess->sessid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%ldus since last read on encoding session %lu\n", (long)difftime, sess->sessid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,11 +549,12 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sess->encoder.debug_timing) {
|
if (sess->encoder.debug_timing) {
|
||||||
afterread_time = switch_micro_time_now();
|
func_end_time = switch_micro_time_now();
|
||||||
difftime = afterread_time - prevread_time;
|
difftime = func_end_time - func_start_time;
|
||||||
if (difftime > 5000) {
|
if (difftime > 5000) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%ldus to execute encoding function in session %lu.\n", (long)difftime, sess->sessid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%ldus to execute encoding function in session %lu.\n", (long)difftime, sess->sessid);
|
||||||
}
|
}
|
||||||
|
sess->encoder.last_func_call_time = func_end_time;
|
||||||
}
|
}
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -576,14 +575,14 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
|
|||||||
switch_frame_t ulaw_frame;
|
switch_frame_t ulaw_frame;
|
||||||
switch_status_t sres;
|
switch_status_t sres;
|
||||||
switch_time_t now_time, difftime;
|
switch_time_t now_time, difftime;
|
||||||
switch_time_t prevread_time, afterread_time;
|
switch_time_t func_start_time, func_end_time;
|
||||||
short *dbuf_linear;
|
short *dbuf_linear;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct sangoma_transcoding_session *sess = codec->private_info;
|
struct sangoma_transcoding_session *sess = codec->private_info;
|
||||||
|
|
||||||
if (sess->decoder.debug_timing) {
|
if (sess->decoder.debug_timing) {
|
||||||
prevread_time = switch_micro_time_now();
|
func_start_time = switch_micro_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
dbuf_linear = decoded_data;
|
dbuf_linear = decoded_data;
|
||||||
@ -613,15 +612,12 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
|
|||||||
switch_mutex_unlock(g_sessions_lock);
|
switch_mutex_unlock(g_sessions_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sess->decoder.debug_timing) {
|
if (sess->decoder.debug_timing && sess->decoder.last_func_call_time) {
|
||||||
now_time = switch_micro_time_now();
|
difftime = func_start_time - sess->decoder.last_func_call_time;
|
||||||
if (sess->decoder.last_rx_time) {
|
|
||||||
difftime = now_time - sess->decoder.last_rx_time;
|
|
||||||
if (difftime > 25000 || difftime < 15000) {
|
if (difftime > 25000 || difftime < 15000) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%ldms since last read on decoding session %lu.\n", (long)difftime, sess->sessid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%ldms since last read on decoding session %lu.\n", (long)difftime, sess->sessid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* do the writing */
|
/* do the writing */
|
||||||
memset(&encoded_frame, 0, sizeof(encoded_frame));
|
memset(&encoded_frame, 0, sizeof(encoded_frame));
|
||||||
@ -743,11 +739,12 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sess->decoder.debug_timing) {
|
if (sess->decoder.debug_timing) {
|
||||||
afterread_time = switch_micro_time_now();
|
func_end_time = switch_micro_time_now();
|
||||||
difftime = afterread_time - prevread_time;
|
difftime = func_end_time - func_start_time;
|
||||||
if (difftime > 5000) {
|
if (difftime > 5000) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%ldus to execute decoding function in session %lu.\n", (long)difftime, sess->sessid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%ldus to execute decoding function in session %lu.\n", (long)difftime, sess->sessid);
|
||||||
}
|
}
|
||||||
|
sess->decoder.last_func_call_time = func_end_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user