clean some old members and naming conventions in the codec structs

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10084 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-10-20 17:48:42 +00:00
parent f1da124229
commit 30c318b995
39 changed files with 240 additions and 245 deletions
@@ -858,7 +858,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
{
conference_obj_t *conference = (conference_obj_t *) obj;
conference_member_t *imember, *omember;
uint32_t samples = switch_samples_per_frame(conference->rate, conference->interval);
uint32_t samples = switch_samples_per_packet(conference->rate, conference->interval);
uint32_t bytes = samples * 2;
uint8_t ready = 0, total = 0;
switch_timer_t timer = { 0 };
@@ -1737,17 +1737,17 @@ static void conference_loop_output(conference_member_t *member)
uint8_t *data;
switch_timer_t timer = { 0 };
switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session);
uint32_t interval = read_codec->implementation->microseconds_per_frame / 1000;
uint32_t samples = switch_samples_per_frame(member->conference->rate, interval);
uint32_t interval = read_codec->implementation->microseconds_per_packet / 1000;
uint32_t samples = switch_samples_per_packet(member->conference->rate, interval);
uint32_t csamples = samples;
uint32_t tsamples = member->orig_read_codec->implementation->samples_per_frame;
uint32_t tsamples = member->orig_read_codec->implementation->samples_per_packet;
uint32_t flush_len = 0;
uint32_t low_count = 0, bytes = samples * 2;
call_list_t *call_list = NULL, *cp = NULL;
switch_assert(member->conference != NULL);
flush_len = switch_samples_per_frame(member->conference->rate, member->conference->interval) * 10;
flush_len = switch_samples_per_packet(member->conference->rate, member->conference->interval) * 10;
if (switch_core_timer_init(&timer, member->conference->timer_name, interval, tsamples, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n");
@@ -2044,7 +2044,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
conference_member_t smember = { 0 }, *member;
conference_record_t *rec = (conference_record_t *) obj;
conference_obj_t *conference = rec->conference;
uint32_t samples = switch_samples_per_frame(conference->rate, conference->interval);
uint32_t samples = switch_samples_per_packet(conference->rate, conference->interval);
uint32_t low_count = 0, mux_used;
char *vval;
switch_timer_t timer = { 0 };
@@ -4444,15 +4444,15 @@ SWITCH_STANDARD_APP(conference_function)
/* Setup a Signed Linear codec for reading audio. */
if (switch_core_codec_init(&member.read_codec,
"L16",
NULL, read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000,
NULL, read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
flags = 0;
goto done;
@@ -4488,14 +4488,14 @@ SWITCH_STANDARD_APP(conference_function)
"L16",
NULL,
conference->rate,
read_codec->implementation->microseconds_per_frame / 1000,
read_codec->implementation->microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member.pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
conference->rate, read_codec->implementation->microseconds_per_frame / 1000);
conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
conference->rate, read_codec->implementation->microseconds_per_frame / 1000);
conference->rate, read_codec->implementation->microseconds_per_packet / 1000);
flags = 0;
goto codec_done2;
}
+2 -2
View File
@@ -188,8 +188,8 @@ SWITCH_STANDARD_APP(bcast_function)
mcast_ip,
mcast_port,
read_codec->implementation->ianacode,
read_codec->implementation->samples_per_frame,
read_codec->implementation->microseconds_per_frame,
read_codec->implementation->samples_per_packet,
read_codec->implementation->microseconds_per_packet,
(switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session));
if (!switch_rtp_ready(rtp_session)) {
+4 -4
View File
@@ -577,12 +577,12 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
"L16",
NULL,
orig_read_codec->implementation->samples_per_second,
orig_read_codec->implementation->microseconds_per_frame / 1000,
orig_read_codec->implementation->microseconds_per_packet / 1000,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw read codec activation Success L16 %u\n",
read_codec.implementation->microseconds_per_frame);
read_codec.implementation->microseconds_per_packet);
switch_core_session_set_read_codec(session, &read_codec);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Raw read codec activation Failed L16\n");
@@ -593,7 +593,7 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
"L16",
NULL,
orig_read_codec->implementation->samples_per_second,
orig_read_codec->implementation->microseconds_per_frame / 1000,
orig_read_codec->implementation->microseconds_per_packet / 1000,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
@@ -640,7 +640,7 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
}
}
if ((tx = fax_tx(pvt->fax_state, buf, write_codec.implementation->samples_per_frame)) < 0) {
if ((tx = fax_tx(pvt->fax_state, buf, write_codec.implementation->samples_per_packet)) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fax_tx reported an error\n");
goto done;
}
+4 -4
View File
@@ -123,7 +123,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
"L16",
NULL,
read_codec->implementation->samples_per_second,
read_codec->implementation->microseconds_per_frame / 1000,
read_codec->implementation->microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
@@ -146,7 +146,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
switch_set_string(h.video_fmtp, vid_codec->fmtp_in);
}
h.audio_rate = read_codec->implementation->samples_per_second;
h.audio_ptime = read_codec->implementation->microseconds_per_frame / 1000;
h.audio_ptime = read_codec->implementation->microseconds_per_packet / 1000;
if (write(fd, &h, sizeof(h)) != sizeof(h)) {
goto end;
@@ -265,8 +265,8 @@ SWITCH_STANDARD_APP(play_fsv_function)
read_codec = switch_core_session_get_read_codec(session);
if (switch_core_timer_init(&timer, "soft", read_codec->implementation->microseconds_per_frame / 1000,
read_codec->implementation->samples_per_frame, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
if (switch_core_timer_init(&timer, "soft", read_codec->implementation->microseconds_per_packet / 1000,
read_codec->implementation->samples_per_packet, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Activation Fail\n");
goto end;
}
+1 -1
View File
@@ -186,7 +186,7 @@ SWITCH_STANDARD_APP(rss_function)
const char *vcf = NULL;
char *chanvars = switch_channel_build_param_string(channel, NULL, NULL);
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
uint32_t rate, interval = read_codec->implementation->microseconds_per_frame / 1000;
uint32_t rate, interval = read_codec->implementation->microseconds_per_packet / 1000;
if ((vcf = switch_channel_get_variable(channel, "rss_alt_config"))) {
cf = vcf;
+3 -3
View File
@@ -285,7 +285,7 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
}
Decoder_Interface_Decode(context->decoder_state, (unsigned char *) encoded_data, (int16_t *) decoded_data, 0);
*decoded_data_len = codec->implementation->bytes_per_frame;
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
return SWITCH_STATUS_SUCCESS;
#endif
@@ -320,8 +320,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_amr_load)
SWITCH_ADD_CODEC(codec_interface, "AMR");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200,
20000, 160, 320, 0, 1, 1, 1, switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
SWITCH_CODEC_TYPE_AUDIO, 96, "AMR", "octet-align=0", 8000, 8000, 12200, 20000, 160, 320, 0, 1, 1,
switch_amr_init, switch_amr_encode, switch_amr_decode, switch_amr_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
+3 -3
View File
@@ -131,7 +131,7 @@ static switch_status_t switch_g723_encode(switch_codec_t *codec,
}
Coder(&context->encoder_object, (FLOAT *) context->cod_float_buf, ebuf);
*encoded_data_len = codec->implementation->encoded_bytes_per_frame;
*encoded_data_len = codec->implementation->encoded_bytes_per_packet;
return SWITCH_STATUS_SUCCESS;
#endif
@@ -161,7 +161,7 @@ static switch_status_t switch_g723_decode(switch_codec_t *codec,
for (x = 0; x < Frame; x++) {
to_slin_buf[x] = context->dec_float_buf[x];
}
*decoded_data_len = codec->implementation->bytes_per_frame;
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
return SWITCH_STATUS_SUCCESS;
#endif
@@ -177,7 +177,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g723_1_load)
for (count = 1; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 4,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count,
switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
}
/* indicate that the module should continue to be loaded */
+1 -1
View File
@@ -218,7 +218,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_g729_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 18, "G729", NULL, 8000, 8000, 8000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g729_init, switch_g729_encode, switch_g729_decode, switch_g729_destroy);
}
/* indicate that the module should continue to be loaded */
+5 -5
View File
@@ -85,23 +85,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_h26x_load)
SWITCH_ADD_CODEC(codec_interface, "H.264 Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 99, "H264", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
SWITCH_ADD_CODEC(codec_interface, "H.263 Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 34, "H263", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
SWITCH_ADD_CODEC(codec_interface, "H.263+ Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 115, "H263-1998", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
SWITCH_ADD_CODEC(codec_interface, "H.263++ Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 121, "H263-2000", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
SWITCH_ADD_CODEC(codec_interface, "H.261 Video (passthru)");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 31, "H261", NULL, 90000, 90000, 0,
0, 0, 0, 0, 1, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
0, 0, 0, 0, 1, 1, switch_h26x_init, switch_h26x_encode, switch_h26x_decode, switch_h26x_destroy);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
+7 -7
View File
@@ -50,7 +50,7 @@ static switch_status_t switch_ilbc_init(switch_codec_t *codec, switch_codec_flag
{
struct ilbc_context *context;
int encoding, decoding;
uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_frame / 1000);
uint8_t ms = (uint8_t) (codec->implementation->microseconds_per_packet / 1000);
if (ms != 20 && ms != 30) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid speed! (I should never happen)\n");
@@ -189,28 +189,28 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_ilbc_load)
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 97, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC102", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC20ms", "mode=20", 8000, 8000, NO_OF_BYTES_20MS * 8 * 8000 / BLOCKL_20MS,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1, 1,
20000, 160, 320, NO_OF_BYTES_20MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
/* 30ms variants */
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 98, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 102, "iLBC", "mode=30", 8000, 8000, NO_OF_BYTES_30MS * 8 * 8000 / BLOCKL_30MS,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1, 1,
30000, 240, 480, NO_OF_BYTES_30MS, 1, 1,
switch_ilbc_init, switch_ilbc_encode, switch_ilbc_decode, switch_ilbc_destroy);
/* indicate that the module should continue to be loaded */
+2 -2
View File
@@ -229,7 +229,7 @@ static switch_status_t switch_speex_decode(switch_codec_t *codec,
speex_bits_read_from(&context->decoder_bits, (char *) encoded_data, (int) encoded_data_len);
speex_decode_int(context->decoder_state, &context->decoder_bits, buf);
}
*decoded_data_len = codec->implementation->bytes_per_frame;
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
return SWITCH_STATUS_SUCCESS;
}
@@ -274,7 +274,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_speex_load)
for (countb = 1; countb > 0; countb--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "SPEEX", NULL, rate, rate, bps[counta],
mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1, 6,
mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, 1,
switch_speex_init, switch_speex_encode, switch_speex_decode, switch_speex_destroy);
}
rate = rate * 2;
+19 -19
View File
@@ -242,8 +242,8 @@ static switch_status_t switch_g711u_decode(switch_codec_t *codec,
ebuf = encoded_data;
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
memset(dbuf, 0, codec->implementation->bytes_per_frame);
*decoded_data_len = codec->implementation->bytes_per_frame;
memset(dbuf, 0, codec->implementation->decoded_bytes_per_packet);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
} else {
for (i = 0; i < encoded_data_len; i++) {
dbuf[i] = ulaw_to_linear(ebuf[i]);
@@ -313,8 +313,8 @@ static switch_status_t switch_g711a_decode(switch_codec_t *codec,
ebuf = encoded_data;
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
memset(dbuf, 0, codec->implementation->bytes_per_frame);
*decoded_data_len = codec->implementation->bytes_per_frame;
memset(dbuf, 0, codec->implementation->decoded_bytes_per_packet);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
} else {
for (i = 0; i < encoded_data_len; i++) {
dbuf[i] = alaw_to_linear(ebuf[i]);
@@ -569,14 +569,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 5, "DVI4", NULL, 8000, 8000, 32000,
mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, spf * count,
switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
}
mpf = 10000, spf = 160, bpf = 320, ebpf = 160;
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 6, "DVI4", NULL, 16000, 16000, 64000,
mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, 1, 12,
mpf * count, spf * count, bpf * count, (ebpf * count) + 4, 1, spf * count,
switch_adpcm_init, switch_adpcm_encode, switch_adpcm_decode, switch_adpcm_destroy);
}
@@ -586,14 +586,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 124, "AAL2-G726-16", NULL, 8000, 8000, 16000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 127, "G726-16", NULL, 8000, 8000, 16000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
/* Increase encoded bytes per frame by 10 */
@@ -603,14 +603,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 123, "AAL2-G726-24", NULL, 8000, 8000, 24000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 126, "G726-24", NULL, 8000, 8000, 24000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
/* Increase encoded bytes per frame by 10 */
@@ -620,14 +620,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 2, "AAL2-G726-32", NULL, 8000, 8000, 32000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 2, "G726-32", NULL, 8000, 8000, 32000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
/* Increase encoded bytes per frame by 10 */
@@ -637,14 +637,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 122, "AAL2-G726-40", NULL, 8000, 8000, 40000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 125, "G726-40", NULL, 8000, 8000, 40000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count * 10,
switch_g726_init, switch_g726_encode, switch_g726_decode, switch_g726_destroy);
}
@@ -654,7 +654,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 9, "G722", NULL, 8000, 16000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, spf * count,
switch_g722_init, switch_g722_encode, switch_g722_decode, switch_g722_destroy);
}
@@ -665,7 +665,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 0, "PCMU", NULL, 8000, 8000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, spf * count,
switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
}
@@ -673,7 +673,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 12; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 8, "PCMA", NULL, 8000, 8000, 64000,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 12,
mpf * count, spf * count, bpf * count, ebpf * count, 1, spf * count,
switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
}
#endif
@@ -684,7 +684,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
for (count = 6; count > 0; count--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 3, "GSM", NULL, 8000, 8000, 13200,
mpf * count, spf * count, bpf * count, ebpf * count, 1, 1, 6,
mpf * count, spf * count, bpf * count, ebpf * count, 1, count,
switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
}
/* LPC10 */
@@ -692,7 +692,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
SWITCH_ADD_CODEC(codec_interface, "LPC-10");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
90000, 720, 1440, 28, 1, 1, 1, switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
90000, 720, 1440, 28, 1, 4, switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
#endif
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
+7 -7
View File
@@ -272,7 +272,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
}
}
switch_yield(globals.read_codec.implementation->microseconds_per_frame);
switch_yield(globals.read_codec.implementation->microseconds_per_packet);
}
switch_clear_flag_locked((&globals), GFLAG_RING);
@@ -578,14 +578,14 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
goto hold;
}
cng:
switch_yield(globals.read_codec.implementation->microseconds_per_frame);
switch_yield(globals.read_codec.implementation->microseconds_per_packet);
*frame = &globals.cng_frame;
return SWITCH_STATUS_SUCCESS;
hold:
{
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
switch_size_t olen = globals.read_codec.implementation->samples_per_packet;
if (switch_core_timer_next(&tech_pvt->timer) != SWITCH_STATUS_SUCCESS) {
switch_core_file_close(&tech_pvt->fh);
switch_core_codec_destroy(&tech_pvt->write_codec);
@@ -611,7 +611,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
}
switch_mutex_lock(globals.device_lock);
if ((samples = snd_pcm_readi(globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_frame)) > 0) {
if ((samples = snd_pcm_readi(globals.audio_stream_in, globals.read_frame.data, globals.read_codec.implementation->samples_per_packet)) > 0) {
globals.read_frame.datalen = samples * 2;
globals.read_frame.samples = samples;
@@ -990,7 +990,7 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
}
if (switch_core_timer_init(&globals.timer,
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame, module_pool) != SWITCH_STATUS_SUCCESS) {
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
switch_core_codec_destroy(&globals.read_codec);
switch_core_codec_destroy(&globals.write_codec);
@@ -1088,12 +1088,12 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
goto fail;
}
if ((err = snd_pcm_hw_params_set_period_time(globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_frame, 0)) < 0) {
if ((err = snd_pcm_hw_params_set_period_time(globals.audio_stream_in, hw_params, globals.read_codec.implementation->microseconds_per_packet, 0)) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period time (%s)\n", snd_strerror(err));
goto fail;
}
if ((err = snd_pcm_hw_params_set_period_size(globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_frame, 0)) < 0) {
if ((err = snd_pcm_hw_params_set_period_size(globals.audio_stream_in, hw_params, globals.read_codec.implementation->samples_per_packet, 0)) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cannot set period size (%s)\n", snd_strerror(err));
goto fail;
}
@@ -879,8 +879,8 @@ static int activate_rtp(struct private_object *tech_pvt)
tech_pvt->remote_ip,
tech_pvt->remote_port,
tech_pvt->codec_num,
tech_pvt->read_codec.implementation->samples_per_frame,
tech_pvt->read_codec.implementation->microseconds_per_frame,
tech_pvt->read_codec.implementation->samples_per_packet,
tech_pvt->read_codec.implementation->microseconds_per_packet,
flags, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -1389,10 +1389,10 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
int frames = 1;
if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet)) {
frames = (tech_pvt->read_frame.datalen / bytes);
}
tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_packet);
}
break;
}
@@ -1440,13 +1440,13 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
if (!switch_test_flag(frame, SFF_CNG)) {
if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet;
frames = ((int) frame->datalen / bytes);
} else
frames = 1;
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
samples = frames * tech_pvt->read_codec.implementation->samples_per_packet;
}
#if 0
printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n",
+9 -9
View File
@@ -256,7 +256,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
}
leading = iana2ast(codecs[0]->ianacode);
interval = codecs[0]->microseconds_per_frame / 1000;
interval = codecs[0]->microseconds_per_packet / 1000;
if (io == IAX_QUERY) {
chosen = leading;
*format = chosen;
@@ -296,7 +296,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
for (imp = codecs[z]; imp; imp = imp->next) {
if (prefs[x] == iana2ast(imp->ianacode)) {
dname = imp->iananame;
interval = imp->microseconds_per_frame / 1000;
interval = imp->microseconds_per_packet / 1000;
break;
}
}
@@ -313,7 +313,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
unsigned int cap = iana2ast(imp->ianacode);
if (cap == chosen) {
dname = imp->iananame;
interval = imp->microseconds_per_frame / 1000;
interval = imp->microseconds_per_packet / 1000;
break;
}
}
@@ -326,7 +326,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
if (cap & mixed_cap) {
chosen = cap;
dname = imp->iananame;
interval = imp->microseconds_per_frame / 1000;
interval = imp->microseconds_per_packet / 1000;
break;
}
}
@@ -393,7 +393,7 @@ static switch_status_t iax_set_codec(private_t *tech_pvt, struct iax_session *ia
} else {
int ms;
int rate;
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
ms = tech_pvt->write_codec.implementation->microseconds_per_packet / 1000;
rate = tech_pvt->write_codec.implementation->samples_per_second;
tech_pvt->read_frame.rate = rate;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Activate Codec %s/%d %d ms\n", dname, rate, ms);
@@ -646,7 +646,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
switch_swap_linear(frame->data, (int) frame->datalen / 2);
}
#endif
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int) frame->datalen, tech_pvt->write_codec.implementation->samples_per_packet);
return SWITCH_STATUS_SUCCESS;
@@ -1086,14 +1086,14 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
break;
}
if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet;
frames = (int) (tech_pvt->read_frame.datalen / bytes);
} else {
frames = 1;
}
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_packet;
memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
/* wake up the i/o thread */
switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
@@ -107,7 +107,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
if (codec) {
iananame = codec->implementation->iananame;
rate = codec->implementation->samples_per_second;
interval = codec->implementation->microseconds_per_frame / 1000;
interval = codec->implementation->microseconds_per_packet / 1000;
}
if (tech_pvt->read_codec.implementation) {
@@ -163,7 +163,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
tech_pvt->cng_frame.datalen = 2;
tech_pvt->bowout_frame_count = (tech_pvt->read_codec.implementation->actual_samples_per_second /
tech_pvt->read_codec.implementation->samples_per_frame) * 3;
tech_pvt->read_codec.implementation->samples_per_packet) * 3;
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
@@ -175,8 +175,8 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
read_impl = tech_pvt->read_codec.implementation;
switch_core_timer_init(&tech_pvt->timer, "soft",
read_impl->microseconds_per_frame / 1000,
read_impl->samples_per_frame *4,
read_impl->microseconds_per_packet / 1000,
read_impl->samples_per_packet *4,
switch_core_session_get_pool(session));
@@ -492,7 +492,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
if (!is_master(tech_pvt)) {
if (tech_pvt->hold_file) {
switch_size_t olen = globals.read_codec.implementation->samples_per_frame;
switch_size_t olen = globals.read_codec.implementation->samples_per_packet;
if (!tech_pvt->hfh) {
int sample_rate = tech_pvt->sample_rate ? tech_pvt->sample_rate : globals.sample_rate;
@@ -541,7 +541,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
switch_mutex_lock(globals.device_lock);
samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
globals.read_codec.implementation->samples_per_frame, &globals.timer);
globals.read_codec.implementation->samples_per_packet, &globals.timer);
switch_mutex_unlock(globals.device_lock);
if (samples) {
@@ -740,7 +740,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load)
globals.read_frame.buflen = sizeof(globals.databuf);
globals.cng_frame.data = globals.cngbuf;
globals.cng_frame.buflen = sizeof(globals.cngbuf);
globals.cng_frame.datalen = switch_samples_per_frame(globals.sample_rate, globals.codec_ms) * 2;
globals.cng_frame.datalen = switch_samples_per_packet(globals.sample_rate, globals.codec_ms) * 2;
switch_set_flag((&globals.cng_frame), SFF_CNG);
/* connect my internal structure to the blank pointer passed to me */
@@ -1161,7 +1161,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
}
if (switch_core_timer_init(&globals.timer,
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame,
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
switch_core_codec_destroy(&globals.read_codec);
@@ -1170,7 +1170,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
}
if (switch_core_timer_init(&globals.hold_timer,
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_frame,
globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
module_pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n");
switch_core_codec_destroy(&globals.read_codec);
@@ -1196,7 +1196,7 @@ static switch_status_t engage_device(int sample_rate, int codec_ms)
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
globals.read_codec.implementation->samples_per_frame);
globals.read_codec.implementation->samples_per_packet);
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
@@ -1232,7 +1232,7 @@ static switch_status_t engage_ring_device(int sample_rate, int channels)
outputParameters.sampleFormat = SAMPLE_TYPE;
outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff, globals.read_codec.implementation->samples_per_frame);
err = OpenAudioStream(&globals.ring_stream, NULL, &outputParameters, sample_rate, paClipOff, globals.read_codec.implementation->samples_per_packet);
/* UNLOCKED ************************************************************************************************* */
switch_mutex_unlock(globals.device_lock);
+3 -3
View File
@@ -218,7 +218,7 @@ static unsigned long RoundUpToNextPowerOf2(unsigned long n)
*/
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
const PaStreamParameters * inputParameters,
const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags, long samples_per_frame)
const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags, long samples_per_packet)
{
long bytesPerSample = 2;
PaError err;
@@ -244,7 +244,7 @@ PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
channels = outputParameters->channelCount;
}
numFrames = RoundUpToNextPowerOf2(samples_per_frame * 5);
numFrames = RoundUpToNextPowerOf2(samples_per_packet * 5);
aStream->bytesPerFrame = bytesPerSample;
/* Initialize Ring Buffers */
@@ -268,7 +268,7 @@ PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
/* Open a PortAudio stream that we will use to communicate with the underlying
* audio drivers. */
err = Pa_OpenStream(&aStream->stream, inputParameters, outputParameters, sampleRate, samples_per_frame, streamFlags, blockingIOCallback, aStream);
err = Pa_OpenStream(&aStream->stream, inputParameters, outputParameters, sampleRate, samples_per_packet, streamFlags, blockingIOCallback, aStream);
if (err != paNoError)
goto error;
+1 -1
View File
@@ -104,7 +104,7 @@ extern "C" {
*/
PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
const PaStreamParameters * inputParameters,
const PaStreamParameters * outputParameters, double sampleRate, PaStreamCallbackFlags statusFlags, long samples_per_frame);
const PaStreamParameters * outputParameters, double sampleRate, PaStreamCallbackFlags statusFlags, long samples_per_packet);
PaError CloseAudioStream(PABLIO_Stream * aStream);
+5 -5
View File
@@ -664,10 +664,10 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
*frame = NULL;
return SWITCH_STATUS_GENERR;
}
if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) {
if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet)) {
frames = (tech_pvt->read_frame.datalen / bytes);
}
tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_frame);
tech_pvt->read_frame.samples = (int) (frames * tech_pvt->read_codec.implementation->samples_per_packet);
}
break;
}
@@ -722,13 +722,13 @@ static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
if (tech_pvt->read_codec.implementation->encoded_bytes_per_frame) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
if (tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_packet;
frames = ((int) frame->datalen / bytes);
} else
frames = 1;
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
samples = frames * tech_pvt->read_codec.implementation->samples_per_packet;
}
tech_pvt->timestamp_send += samples;
+18 -18
View File
@@ -118,7 +118,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
if (!ptime) {
ptime = imp->microseconds_per_frame / 1000;
ptime = imp->microseconds_per_packet / 1000;
}
}
}
@@ -141,7 +141,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->agreed_pt, tech_pvt->fmtp_out);
}
if (tech_pvt->read_codec.implementation && !ptime) {
ptime = tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
ptime = tech_pvt->read_codec.implementation->microseconds_per_packet / 1000;
}
} else if (tech_pvt->num_codecs) {
@@ -253,7 +253,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", imp->ianacode);
if (!ptime) {
ptime = imp->microseconds_per_frame / 1000;
ptime = imp->microseconds_per_packet / 1000;
}
}
}
@@ -1487,7 +1487,7 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
} else {
int ms;
tech_pvt->video_read_frame.rate = tech_pvt->video_rm_rate;
ms = tech_pvt->video_write_codec.implementation->microseconds_per_frame / 1000;
ms = tech_pvt->video_write_codec.implementation->microseconds_per_packet / 1000;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set VIDEO Codec %s %s/%ld %d ms\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
@@ -1555,7 +1555,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
}
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
ms = tech_pvt->write_codec.implementation->microseconds_per_packet / 1000;
if (!tech_pvt->read_codec.implementation) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
@@ -1564,7 +1564,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
switch_channel_get_name(tech_pvt->channel), tech_pvt->iananame, tech_pvt->rm_rate, tech_pvt->codec_ms,
tech_pvt->read_codec.implementation->samples_per_frame);
tech_pvt->read_codec.implementation->samples_per_packet);
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
tech_pvt->write_codec.agreed_pt = tech_pvt->agreed_pt;
@@ -1721,7 +1721,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
}
bw = tech_pvt->read_codec.implementation->bits_per_second;
ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
ms = tech_pvt->read_codec.implementation->microseconds_per_packet;
if (myflags) {
flags = myflags;
@@ -1784,7 +1784,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
}
switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
@@ -1826,7 +1826,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
} else {
timer_name = tech_pvt->profile->timer_name;
@@ -1841,7 +1841,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->agreed_pt,
tech_pvt->read_codec.implementation->samples_per_frame,
tech_pvt->read_codec.implementation->samples_per_packet,
tech_pvt->codec_ms * 1000,
(switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session));
@@ -1874,7 +1874,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
}
}
stun_ping = (ival * tech_pvt->read_codec.implementation->samples_per_second) / tech_pvt->read_codec.implementation->samples_per_frame;
stun_ping = (ival * tech_pvt->read_codec.implementation->samples_per_second) / tech_pvt->read_codec.implementation->samples_per_packet;
}
tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
@@ -1902,7 +1902,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
} else {
int qlen;
qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
qlen = len / (tech_pvt->read_codec.implementation->microseconds_per_packet / 1000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen);
@@ -1925,7 +1925,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (rtp_timeout_sec) {
tech_pvt->max_missed_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_timeout_sec) /
tech_pvt->read_codec.implementation->samples_per_frame;
tech_pvt->read_codec.implementation->samples_per_packet;
switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
if (!rtp_hold_timeout_sec) {
@@ -1935,7 +1935,7 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
if (rtp_hold_timeout_sec) {
tech_pvt->max_missed_hold_packets = (tech_pvt->read_codec.implementation->samples_per_second * rtp_hold_timeout_sec) /
tech_pvt->read_codec.implementation->samples_per_frame;
tech_pvt->read_codec.implementation->samples_per_packet;
}
if (tech_pvt->te) {
@@ -2362,7 +2362,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
}
if (match) {
if ((ptime && ptime * 1000 != imp->microseconds_per_frame) || map->rm_rate != codec_rate) {
if ((ptime && ptime * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
near_rate = map->rm_rate;
near_match = imp;
match = 0;
@@ -2393,7 +2393,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
mimp->iananame, mimp->microseconds_per_frame / 1000, mimp->samples_per_second);
mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
match = 1;
}
@@ -2408,7 +2408,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
tech_pvt->iananame = switch_core_session_strdup(session, (char *) mimp->iananame);
tech_pvt->pt = (switch_payload_t) map->rm_pt;
tech_pvt->rm_rate = map->rm_rate;
tech_pvt->codec_ms = mimp->microseconds_per_frame / 1000;
tech_pvt->codec_ms = mimp->microseconds_per_packet / 1000;
tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(session, (char *) connection->c_address);
tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
@@ -2492,7 +2492,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
char tmp[50];
tech_pvt->video_pt = (switch_payload_t) map->rm_pt;
tech_pvt->video_rm_rate = map->rm_rate;
tech_pvt->video_codec_ms = mimp->microseconds_per_frame / 1000;
tech_pvt->video_codec_ms = mimp->microseconds_per_packet / 1000;
tech_pvt->remote_sdp_video_ip = switch_core_session_strdup(session, (char *) connection->c_address);
tech_pvt->video_rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
tech_pvt->remote_sdp_video_port = (switch_port_t) m->m_port;
@@ -193,7 +193,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
}
source->rate = fh.samplerate;
source->samples = switch_samples_per_frame(fh.native_rate, source->interval);
source->samples = switch_samples_per_packet(fh.native_rate, source->interval);
if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, source->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n");
@@ -473,7 +473,7 @@ static void launch_threads(void)
}
}
source->samples = switch_samples_per_frame(source->rate, source->interval);
source->samples = switch_samples_per_packet(source->rate, source->interval);
switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);
@@ -693,7 +693,7 @@ SWITCH_STANDARD_API(start_local_stream_function)
source->prebuf = prebuf;
source->stopped = 0;
source->samples = switch_samples_per_frame(source->rate, source->interval);
source->samples = switch_samples_per_packet(source->rate, source->interval);
switch_mutex_init(&source->mutex, SWITCH_MUTEX_NESTED, source->pool);
@@ -1839,7 +1839,7 @@ static switch_status_t init_speech_engine(struct js_session *jss, char *engine,
read_codec = switch_core_session_get_read_codec(jss->session);
rate = read_codec->implementation->actual_samples_per_second;
interval = read_codec->implementation->microseconds_per_frame / 1000;
interval = read_codec->implementation->microseconds_per_packet / 1000;
if (switch_core_codec_init(&jss->speech->codec,
"L16",
@@ -113,7 +113,7 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
"L16",
NULL,
read_codec->implementation->actual_samples_per_second,
read_codec->implementation->microseconds_per_frame / 1000,
read_codec->implementation->microseconds_per_packet / 1000,
read_codec->implementation->number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
@@ -123,7 +123,7 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
}
if (timer_name) {
unsigned int ms = read_codec->implementation->microseconds_per_frame / 1000;
unsigned int ms = read_codec->implementation->microseconds_per_packet / 1000;
if (switch_core_timer_init(&tto->timer_base,
timer_name,
ms,
@@ -279,7 +279,7 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
}
}
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(tto->audio_buffer,
fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) {
fdata, write_frame.codec->implementation->decoded_bytes_per_packet)) <= 0) {
break;
}