mod_sangoma_codec: do not return 0 len frames and return silence instead when there is no transcoding output

update stats only when we really receive a frame
This commit is contained in:
Moises Silva 2010-10-06 12:36:40 -04:00
parent 8f13eb8966
commit dc4d19e9f6

View File

@ -447,9 +447,12 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
*encoded_data_len = encoded_frame.datalen;
}
/* update encoding stats */
/* update encoding stats if we received a frame */
if (*encoded_data_len) {
if (*encoded_data_len != codec->implementation->encoded_bytes_per_packet) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Returning odd encoded frame of %d bytes intead of %d bytes\n", *encoded_data_len, codec->implementation->encoded_bytes_per_packet);
}
sess->encoder.rx++;
now_time = switch_micro_time_now();
if (!sess->encoder.last_rx_time) {
sess->encoder.last_rx_time = now_time;
@ -466,6 +469,9 @@ static switch_status_t switch_sangoma_encode(switch_codec_t *codec, switch_codec
}
}
sess->encoder.lastrxseqno = encoded_frame.seq;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output from sangoma encoder\n");
}
return SWITCH_STATUS_SUCCESS;
}
@ -570,6 +576,10 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
*decoded_data_len = i * 2;
}
if (*decoded_data_len) {
if (*decoded_data_len != codec->implementation->decoded_bytes_per_packet) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Returning odd decoded frame of %d bytes intead of %d bytes\n", *decoded_data_len, codec->implementation->decoded_bytes_per_packet);
}
/* update decoding stats */
sess->decoder.rx++;
@ -589,6 +599,11 @@ static switch_status_t switch_sangoma_decode(switch_codec_t *codec, /* codec ses
}
}
sess->decoder.lastrxseqno = ulaw_frame.seq;
} else {
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output from sangoma decoder, returning silent frame of %d bytes\n", *decoded_data_len);
memset(dbuf_linear, 0, *decoded_data_len);
}
return SWITCH_STATUS_SUCCESS;
}