/*! bits transferred per second */
int bits_per_second,
/*! number of microseconds that denote one frame */
- int microseconds_per_frame,
+ int microseconds_per_packet,
/*! number of samples that denote one frame */
- uint32_t samples_per_frame,
+ uint32_t samples_per_packet,
/*! number of bytes that denote one frame decompressed */
- uint32_t bytes_per_frame,
+ uint32_t decoded_bytes_per_packet,
/*! number of bytes that denote one frame compressed */
- uint32_t encoded_bytes_per_frame,
+ uint32_t encoded_bytes_per_packet,
/*! number of channels represented */
uint8_t number_of_channels,
/*! number of frames to send in one netowrk packet */
- int pref_frames_per_packet,
- /*! max number of frames to send in one network packet */
- int max_frames_per_packet,
+ int codec_frames_per_packet,
/*! function to initialize a codec handle using this implementation */
switch_core_codec_init_func_t init,
/*! function to encode raw data into encoded data */
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy)
{
- if (codec_type == SWITCH_CODEC_TYPE_VIDEO || SWITCH_ACCEPTABLE_INTERVAL(microseconds_per_frame / 1000)) {
+ if (codec_type == SWITCH_CODEC_TYPE_VIDEO || SWITCH_ACCEPTABLE_INTERVAL(microseconds_per_packet / 1000)) {
switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
impl->codec_type = codec_type;
impl->ianacode = ianacode;
impl->samples_per_second = samples_per_second;
impl->actual_samples_per_second = actual_samples_per_second;
impl->bits_per_second = bits_per_second;
- impl->microseconds_per_frame = microseconds_per_frame;
- impl->samples_per_frame = samples_per_frame;
- impl->bytes_per_frame = bytes_per_frame;
- impl->encoded_bytes_per_frame = encoded_bytes_per_frame;
+ impl->microseconds_per_packet = microseconds_per_packet;
+ impl->samples_per_packet = samples_per_packet;
+ impl->decoded_bytes_per_packet = decoded_bytes_per_packet;
+ impl->encoded_bytes_per_packet = encoded_bytes_per_packet;
impl->number_of_channels = number_of_channels;
- impl->pref_frames_per_packet = pref_frames_per_packet;
- impl->max_frames_per_packet = max_frames_per_packet;
+ impl->codec_frames_per_packet = codec_frames_per_packet;
impl->init = init;
impl->encode = encode;
impl->decode = decode;
/*! bits transferred per second */
int bits_per_second;
/*! number of microseconds that denote one frame */
- int microseconds_per_frame;
+ int microseconds_per_packet;
/*! number of samples that denote one frame */
- uint32_t samples_per_frame;
+ uint32_t samples_per_packet;
/*! number of bytes that denote one frame decompressed */
- uint32_t bytes_per_frame;
+ uint32_t decoded_bytes_per_packet;
/*! number of bytes that denote one frame compressed */
- uint32_t encoded_bytes_per_frame;
+ uint32_t encoded_bytes_per_packet;
/*! number of channels represented */
uint8_t number_of_channels;
- /*! number of frames to send in one netowrk packet */
- int pref_frames_per_packet;
- /*! max number of frames to send in one network packet */
- int max_frames_per_packet;
+ /*! number of codec frames to send in one netowrk packet */
+ int codec_frames_per_packet;
/*! function to initialize a codec handle using this implementation */
switch_core_codec_init_func_t init;
/*! function to encode raw data into encoded data */
#include <switch.h>
SWITCH_BEGIN_EXTERN_C
-#define switch_samples_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
+#define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
#define SWITCH_SMAX 32767
#define SWITCH_SMIN -32768
#define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2;
#define switch_codec2str(codec,buf,len) snprintf(buf, len, "%s@%uh@%ui", \
codec->implementation->iananame, \
codec->implementation->samples_per_second, \
- codec->implementation->microseconds_per_frame / 1000)
+ codec->implementation->microseconds_per_packet / 1000)
#ifdef WIN32
#define switch_is_file_path(file) (file && (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)))
#else
{
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 };
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");
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 };
/* 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;
"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;
}
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)) {
"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");
"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) {
}
}
- 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;
}
"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");
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;
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;
}
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;
}
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
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;
}
}
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
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
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 */
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 */
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;
}
{
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");
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 */
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;
}
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;
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]);
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]);
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);
}
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 */
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 */
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 */
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);
}
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);
}
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);
}
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
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 */
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;
}
}
- 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);
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);
}
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;
}
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);
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;
}
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);
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;
}
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",
}
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;
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;
}
}
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;
}
}
if (cap & mixed_cap) {
chosen = cap;
dname = imp->iananame;
- interval = imp->microseconds_per_frame / 1000;
+ interval = imp->microseconds_per_packet / 1000;
break;
}
}
} 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);
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;
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);
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) {
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);
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));
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;
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) {
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 */
}
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);
}
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);
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);
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);
*/
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;
channels = outputParameters->channelCount;
}
- numFrames = RoundUpToNextPowerOf2(samples_per_frame * 5);
+ numFrames = RoundUpToNextPowerOf2(samples_per_packet * 5);
aStream->bytesPerFrame = bytesPerSample;
/* Initialize Ring Buffers */
/* 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;
*/
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);
*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;
}
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;
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;
}
}
}
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) {
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;
}
}
}
} 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;
}
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");
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;
}
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;
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);
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;
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));
}
}
- 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);
} 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);
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) {
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) {
}
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;
}
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;
}
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;
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;
}
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");
}
}
- 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);
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);
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",
"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");
}
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,
}
}
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;
}
}
}
- if (session->read_codec && codec && session->read_impl.bytes_per_frame) {
+ if (session->read_codec && codec && session->read_impl.decoded_bytes_per_packet) {
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", session->read_impl.iananame);
SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
{
- if (session->read_impl.bytes_per_frame) {
+ if (session->read_impl.decoded_bytes_per_packet) {
*impp = session->read_impl;
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
{
- if (session->write_impl.bytes_per_frame) {
+ if (session->write_impl.decoded_bytes_per_packet) {
*impp = session->write_impl;
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
{
- if (session->video_read_impl.bytes_per_frame) {
+ if (session->video_read_impl.decoded_bytes_per_packet) {
*impp = session->video_read_impl;
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
{
- if (session->video_write_impl.bytes_per_frame) {
+ if (session->video_write_impl.decoded_bytes_per_packet) {
*impp = session->video_write_impl;
return SWITCH_STATUS_SUCCESS;
}
session->write_impl = *codec->implementation;
}
- if (session->write_codec && codec && session->write_impl.bytes_per_frame) {
+ if (session->write_codec && codec && session->write_impl.decoded_bytes_per_packet) {
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", session->write_impl.iananame);
if (!ms) {
for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
if ((!rate || rate == iptr->samples_per_second) &&
- (20 == (iptr->microseconds_per_frame / 1000)) && (!channels || channels == iptr->number_of_channels)) {
+ (20 == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {
implementation = iptr;
goto found;
}
/* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
for (iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
if ((!rate || rate == iptr->samples_per_second) &&
- (!ms || ms == (iptr->microseconds_per_frame / 1000)) && (!channels || channels == iptr->number_of_channels)) {
+ (!ms || ms == (iptr->microseconds_per_packet / 1000)) && (!channels || channels == iptr->number_of_channels)) {
implementation = iptr;
break;
}
if (session->read_frame_count == 0) {
switch_event_t *event;
session->read_frame_count = (session->read_codec->implementation->actual_samples_per_second /
- session->read_codec->implementation->samples_per_frame) * session->track_duration;
+ session->read_codec->implementation->samples_per_packet) * session->track_duration;
switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
switch_channel_event_set_data(session->channel, event);
session->raw_read_frame.datalen = session->raw_read_frame.buflen;
if (is_cng) {
- memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
- session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
+ memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->decoded_bytes_per_packet);
+ session->raw_read_frame.datalen = read_frame->codec->implementation->decoded_bytes_per_packet;
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
read_frame = &session->raw_read_frame;
status = SWITCH_STATUS_SUCCESS;
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->actual_samples_per_second,
- read_frame->codec->implementation->bytes_per_frame,
+ read_frame->codec->implementation->decoded_bytes_per_packet,
session->read_codec->implementation->actual_samples_per_second,
- session->read_codec->implementation->bytes_per_frame, session->pool);
+ session->read_codec->implementation->decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_SUCCESS;
break;
case SWITCH_STATUS_BREAK:
- memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->bytes_per_frame);
- session->raw_read_frame.datalen = read_frame->codec->implementation->bytes_per_frame;
+ memset(session->raw_read_frame.data, 255, read_frame->codec->implementation->decoded_bytes_per_packet);
+ session->raw_read_frame.datalen = read_frame->codec->implementation->decoded_bytes_per_packet;
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
session->raw_read_frame.timestamp = read_frame->timestamp;
session->raw_read_frame.rate = read_frame->rate;
}
- if (read_frame->datalen == session->read_codec->implementation->bytes_per_frame) {
+ if (read_frame->datalen == session->read_codec->implementation->decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_read_buffer) {
- switch_size_t bytes = session->read_codec->implementation->bytes_per_frame;
+ switch_size_t bytes = session->read_codec->implementation->decoded_bytes_per_packet;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes vs %u\n",
(uint32_t) bytes, (uint32_t) (*frame)->datalen);
switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
}
- if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->bytes_per_frame) {
+ if (perfect || switch_buffer_inuse(session->raw_read_buffer) >= session->read_codec->implementation->decoded_bytes_per_packet) {
if (perfect) {
enc_frame = read_frame;
session->raw_read_frame.rate = read_frame->rate;
} else {
session->raw_read_frame.datalen = (uint32_t) switch_buffer_read(session->raw_read_buffer,
session->raw_read_frame.data,
- session->read_codec->implementation->bytes_per_frame);
+ session->read_codec->implementation->decoded_bytes_per_packet);
session->raw_read_frame.rate = session->read_codec->implementation->actual_samples_per_second;
enc_frame = &session->raw_read_frame;
case SWITCH_STATUS_RESAMPLE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Fixme 1\n");
case SWITCH_STATUS_SUCCESS:
- session->enc_read_frame.samples = session->read_codec->implementation->bytes_per_frame / sizeof(int16_t);
+ session->enc_read_frame.samples = session->read_codec->implementation->decoded_bytes_per_packet / sizeof(int16_t);
if (perfect) {
session->enc_read_frame.timestamp = read_frame->timestamp;
session->enc_read_frame.rate = read_frame->rate;
*frame = &session->enc_read_frame;
break;
case SWITCH_STATUS_NOOP:
- session->raw_read_frame.samples = enc_frame->codec->implementation->samples_per_frame;
+ session->raw_read_frame.samples = enc_frame->codec->implementation->samples_per_packet;
session->raw_read_frame.timestamp = read_frame->timestamp;
session->raw_read_frame.payload = enc_frame->codec->implementation->ianacode;
session->raw_read_frame.m = read_frame->m;
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
- frame->codec->implementation->bytes_per_frame,
+ frame->codec->implementation->decoded_bytes_per_packet,
session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->bytes_per_frame, session->pool);
+ session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
goto done;
}
if (session->write_codec) {
- if (write_frame->datalen == session->write_codec->implementation->bytes_per_frame) {
+ if (write_frame->datalen == session->write_codec->implementation->decoded_bytes_per_packet) {
perfect = TRUE;
} else {
if (!session->raw_write_buffer) {
- switch_size_t bytes = session->write_codec->implementation->bytes_per_frame;
+ switch_size_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Engaging Write Buffer at %u bytes to accommodate %u->%u\n",
- (uint32_t) bytes, write_frame->datalen, session->write_codec->implementation->bytes_per_frame);
+ (uint32_t) bytes, write_frame->datalen, session->write_codec->implementation->decoded_bytes_per_packet);
if ((status = switch_buffer_create_dynamic(&session->raw_write_buffer,
bytes * SWITCH_BUFFER_BLOCK_FRAMES,
bytes * SWITCH_BUFFER_START_FRAMES, 0)) != SWITCH_STATUS_SUCCESS) {
return status;
} else {
switch_size_t used = switch_buffer_inuse(session->raw_write_buffer);
- uint32_t bytes = session->write_codec->implementation->bytes_per_frame;
+ uint32_t bytes = session->write_codec->implementation->decoded_bytes_per_packet;
switch_size_t frames = (used / bytes);
status = SWITCH_STATUS_SUCCESS;
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
frame->codec->implementation->actual_samples_per_second,
- frame->codec->implementation->bytes_per_frame,
+ frame->codec->implementation->decoded_bytes_per_packet,
session->write_codec->implementation->actual_samples_per_second,
- session->write_codec->implementation->bytes_per_frame, session->pool);
+ session->write_codec->implementation->decoded_bytes_per_packet, session->pool);
switch_mutex_unlock(session->resample_mutex);
if (status != SWITCH_STATUS_SUCCESS) {
bug->stop_time = stop_time;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
- bytes = session->read_codec->implementation->bytes_per_frame;
+ bytes = session->read_codec->implementation->decoded_bytes_per_packet;
if (!bug->flags) {
bug->flags = (SMBF_READ_STREAM | SMBF_WRITE_STREAM);
switch_mutex_init(&bug->read_mutex, SWITCH_MUTEX_NESTED, session->pool);
}
- bytes = session->write_codec->implementation->bytes_per_frame;
+ bytes = session->write_codec->implementation->decoded_bytes_per_packet;
if (switch_test_flag(bug, SMBF_WRITE_STREAM)) {
switch_buffer_create_dynamic(&bug->raw_write_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, MAX_BUG_BUFFER);
sh->rate = rate;
sh->name = switch_core_strdup(pool, module_name);
- sh->samples = switch_samples_per_frame(rate, interval);
+ sh->samples = switch_samples_per_packet(rate, interval);
return sh->speech_interface->speech_open(sh, voice_name, rate, flags);
}
"L16",
NULL,
read_codec->implementation->actual_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,
"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);
goto fail;
}
}
}
rate = read_codec->implementation->actual_samples_per_second;
- bpf = read_codec->implementation->bytes_per_frame;
+ bpf = read_codec->implementation->decoded_bytes_per_packet;
switch_channel_set_flag(channel, CF_CONTROLLED);
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PARK) == SWITCH_STATUS_SUCCESS) {
}
read_codec = switch_core_session_get_read_codec(session);
- interval = read_codec->implementation->microseconds_per_frame / 1000;
- samples = switch_samples_per_frame(read_codec->implementation->samples_per_second, interval);
+ interval = read_codec->implementation->microseconds_per_packet / 1000;
+ samples = switch_samples_per_packet(read_codec->implementation->samples_per_second, interval);
qlen = delay_ms / (interval);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen);
ep = switch_core_session_alloc(session, sizeof(*ep));
- tlen = tread_codec->implementation->bytes_per_frame;
+ tlen = tread_codec->implementation->decoded_bytes_per_packet;
switch_channel_pre_answer(channel);
"L16",
NULL,
tread_codec->implementation->actual_samples_per_second,
- tread_codec->implementation->microseconds_per_frame / 1000,
+ tread_codec->implementation->microseconds_per_packet / 1000,
tread_codec->implementation->number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
"L16",
NULL,
read_codec->implementation->actual_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,
silence_frame.codec = &silence_codec;
silence_frame.data = silence_data;
silence_frame.buflen = sizeof(silence_data);
- silence_frame.datalen = read_codec->implementation->bytes_per_frame;
+ silence_frame.datalen = read_codec->implementation->decoded_bytes_per_packet;
silence_frame.samples = silence_frame.datalen / sizeof(int16_t);
}
}
"L16",
NULL,
read_codec->implementation->actual_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,
"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);
write_frame.codec = &write_codec;
- write_frame.datalen = read_codec->implementation->bytes_per_frame;
+ write_frame.datalen = read_codec->implementation->decoded_bytes_per_packet;
write_frame.samples = write_frame.datalen / 2;
memset(write_frame.data, 255, write_frame.datalen);
unsigned int pos = 0;
if (ringback.asis) {
- mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
+ mlen = write_frame.codec->implementation->encoded_bytes_per_packet;
} else {
- mlen = write_frame.codec->implementation->samples_per_frame;
+ mlen = write_frame.codec->implementation->samples_per_packet;
}
olen = mlen;
} else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
write_frame.data,
- write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+ write_frame.codec->implementation->decoded_bytes_per_packet)) <= 0) {
break;
}
}
"L16",
NULL,
read_codec->implementation->actual_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,
"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->microseconds_per_packet / 1000);
write_frame.codec = &write_codec;
- write_frame.datalen = read_codec->implementation->bytes_per_frame;
+ write_frame.datalen = read_codec->implementation->decoded_bytes_per_packet;
write_frame.samples = write_frame.datalen / 2;
memset(write_frame.data, 255, write_frame.datalen);
unsigned int pos = 0;
if (ringback.asis) {
- mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
+ mlen = write_frame.codec->implementation->encoded_bytes_per_packet;
} else {
- mlen = write_frame.codec->implementation->samples_per_frame;
+ mlen = write_frame.codec->implementation->samples_per_packet;
}
olen = mlen;
} else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
write_frame.data,
- write_frame.codec->implementation->bytes_per_frame)) <= 0) {
+ write_frame.codec->implementation->decoded_bytes_per_packet)) <= 0) {
break;
}
}
codec_name,
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,
switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate,
- fh->channels, read_codec->implementation->microseconds_per_frame / 1000);
+ fh->channels, read_codec->implementation->microseconds_per_packet / 1000);
switch_core_file_close(fh);
switch_core_session_reset(session, SWITCH_TRUE);
return SWITCH_STATUS_GENERR;
if (fh->thresh) {
if (fh->silence_hits) {
- fh->silence_hits = fh->samplerate * fh->silence_hits / read_codec->implementation->samples_per_frame;
+ fh->silence_hits = fh->samplerate * fh->silence_hits / read_codec->implementation->samples_per_packet;
} else {
- fh->silence_hits = fh->samplerate * 3 / read_codec->implementation->samples_per_frame;
+ fh->silence_hits = fh->samplerate * 3 / read_codec->implementation->samples_per_packet;
}
org_silence_hits = fh->silence_hits;
}
"L16",
NULL,
read_codec->implementation->actual_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) {
}
}
- if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data, read_codec->implementation->bytes_per_frame)) <= 0) {
+ if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(audio_buffer, write_frame.data, read_codec->implementation->decoded_bytes_per_packet)) <= 0) {
break;
}
}
switch_assert(read_codec != NULL);
- interval = read_codec->implementation->microseconds_per_frame / 1000;
+ interval = read_codec->implementation->microseconds_per_packet / 1000;
if (!fh->audio_buffer) {
switch_buffer_create_dynamic(&fh->audio_buffer, FILE_BLOCKSIZE, FILE_BUFSIZE, 0);
if (asis) {
write_frame.codec = read_codec;
- samples = read_codec->implementation->samples_per_frame;
- framelen = read_codec->implementation->encoded_bytes_per_frame;
+ samples = read_codec->implementation->samples_per_packet;
+ framelen = read_codec->implementation->encoded_bytes_per_packet;
} else {
codec_name = "L16";
status = SWITCH_STATUS_GENERR;
goto end;
}
- samples = codec.implementation->samples_per_frame;
- framelen = codec.implementation->bytes_per_frame;
+ samples = codec.implementation->samples_per_packet;
+ framelen = codec.implementation->decoded_bytes_per_packet;
}
if (timer_name) {
"L16",
NULL,
read_codec->implementation->actual_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) {
}
if (sample_count) {
- sample_count -= raw_codec.implementation->samples_per_frame;
+ sample_count -= raw_codec.implementation->samples_per_packet;
if (sample_count <= 0) {
break;
}
}
if (abuf) {
- switch_size_t olen = raw_codec.implementation->samples_per_frame;
+ switch_size_t olen = raw_codec.implementation->samples_per_packet;
if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
break;
switch_assert(codec->implementation != NULL);
for (x = 0; !done && x < lead_in_out; x++) {
- switch_yield(codec->implementation->microseconds_per_frame);
+ switch_yield(codec->implementation->microseconds_per_packet);
if (timer) {
write_frame.timestamp = timer->samplecount;
}
if (status != SWITCH_STATUS_SUCCESS) {
for (x = 0; !done && x < lead_in_out; x++) {
- switch_yield(codec->implementation->microseconds_per_frame);
+ switch_yield(codec->implementation->microseconds_per_packet);
if (timer) {
write_frame.timestamp = timer->samplecount;
}
read_codec = switch_core_session_get_read_codec(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 (need_create) {
memset(sh, 0, sizeof(*sh));
key);
break;
}
- if (impl->bytes_per_frame > SWITCH_RECOMMENDED_BUFFER_SIZE) {
+ if (impl->decoded_bytes_per_packet > SWITCH_RECOMMENDED_BUFFER_SIZE) {
load_interface = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
"Failed to load codec interface %s from %s due to bytes per frame exceeding buffer size.\n", ptr->interface_name,
for (impl = ptr->implementations; impl; impl = impl->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Adding Codec '%s' (%s) %dhz %dms\n",
- impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_frame / 1000);
+ impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
if (!switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {
switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) ptr);
}
for (impl = ptr->implementations; impl; impl = impl->next) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
"Deleting Codec '%s' (%s) %dhz %dms\n",
- impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_frame / 1000);
+ impl->iananame, ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
if (switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {
switch_core_hash_delete(loadable_modules.codec_hash, impl->iananame);
}
codec_interface = (switch_codec_interface_t *) val;
/* Look for a 20ms implementation because it's the safest choice */
for (imp = codec_interface->implementations; imp; imp = imp->next) {
- if (imp->microseconds_per_frame / 1000 == 20) {
+ if (imp->microseconds_per_packet / 1000 == 20) {
array[i++] = imp;
goto found;
}
uint8_t match = 1;
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
- if ((uint32_t) (imp->microseconds_per_frame / 1000) != 20) {
+ if ((uint32_t) (imp->microseconds_per_packet / 1000) != 20) {
match = 0;
}
uint8_t match = 1;
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
- if (interval && (uint32_t) (imp->microseconds_per_frame / 1000) != interval) {
+ if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
match = 0;
}
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]);
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]);
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, spf * count, spf * count,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, spf * count,
switch_g711u_init, switch_g711u_encode, switch_g711u_decode, switch_g711u_destroy);
}
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, spf * count, spf * count,
+ mpf * count, spf * count, bpf * count, ebpf * count, 1, spf * count,
switch_g711a_init, switch_g711a_encode, switch_g711a_decode, switch_g711a_destroy);
}
SWITCH_ADD_CODEC(codec_interface, "PROXY VIDEO PASS-THROUGH");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_VIDEO, 31, "PROXY-VID", NULL, 90000, 90000, 0,
- 0, 0, 0, 0, 1, 1, 1, switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
+ 0, 0, 0, 0, 1, 1, switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
SWITCH_ADD_CODEC(codec_interface, "PROXY PASS-THROUGH");
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 0, "PROXY", NULL, 8000, 8000, 0,
- 20000, 160, 320, 320, 1, 1, 12,
+ 20000, 160, 320, 320, 1, 1,
switch_proxy_init, switch_proxy_encode, switch_proxy_decode, switch_proxy_destroy);
SWITCH_ADD_CODEC(codec_interface, "RAW Signed Linear (16 bit)");
for (countb = 12; countb > 0; countb--) {
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, ianacode[counta], "L16", NULL, rate, rate, bps,
- mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, spf * countb, spf * countb,
+ mpf * countb, spf * countb, bpf * countb, ebpf * countb, 1, spf * countb,
switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
}
rate = rate * 2;
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 22050, 22050, 352800,
- 20000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+ 20000, 441, 882, 882, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
switch_core_codec_add_implementation(pool, codec_interface,
SWITCH_CODEC_TYPE_AUDIO, 118, "L16", NULL, 11025, 11025, 176400,
- 40000, 441, 882, 882, 1, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
+ 40000, 441, 882, 882, 1, 1, switch_raw_init, switch_raw_encode, switch_raw_decode, switch_raw_destroy);
codec->implementation->iananame,
NULL,
codec->implementation->samples_per_second,
- codec->implementation->microseconds_per_frame / 1000,
+ codec->implementation->microseconds_per_packet / 1000,
codec->implementation->number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, rtp_session->pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
return SWITCH_STATUS_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Activate VAD codec %s %dms\n", codec->implementation->iananame,
- codec->implementation->microseconds_per_frame / 1000);
+ codec->implementation->microseconds_per_packet / 1000);
rtp_session->vad_data.diff_level = 400;
rtp_session->vad_data.hangunder = 15;
rtp_session->vad_data.hangover = 40;