mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-30 07:04:17 +00:00
spring cleaning
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11730 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
98cb113cdd
commit
be25cc9631
17 files changed
+275
-199
No files matched your search
@@ -291,7 +291,7 @@ struct conference_member {
|
||||
switch_mutex_t *control_mutex;
|
||||
switch_mutex_t *audio_in_mutex;
|
||||
switch_mutex_t *audio_out_mutex;
|
||||
switch_codec_t *orig_read_codec;
|
||||
switch_codec_implementation_t orig_read_impl;
|
||||
switch_codec_t read_codec;
|
||||
switch_codec_t write_codec;
|
||||
char *rec_path;
|
||||
@@ -1773,7 +1773,6 @@ static void conference_loop_output(conference_member_t *member)
|
||||
switch_frame_t write_frame = { 0 };
|
||||
uint8_t *data = NULL;
|
||||
switch_timer_t timer = { 0 };
|
||||
switch_codec_t *read_codec;
|
||||
uint32_t interval;
|
||||
uint32_t samples;
|
||||
uint32_t csamples;
|
||||
@@ -1782,9 +1781,12 @@ static void conference_loop_output(conference_member_t *member)
|
||||
uint32_t low_count, bytes;
|
||||
call_list_t *call_list, *cp;
|
||||
int restarting = -1;
|
||||
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
|
||||
top:
|
||||
|
||||
switch_core_session_get_read_impl(member->session, &read_impl);
|
||||
|
||||
restarting++;
|
||||
|
||||
if (switch_test_flag(member, MFLAG_RESTART)) {
|
||||
@@ -1794,11 +1796,10 @@ static void conference_loop_output(conference_member_t *member)
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(member->session);
|
||||
read_codec = switch_core_session_get_read_codec(member->session);
|
||||
interval = read_codec->implementation->microseconds_per_packet / 1000;
|
||||
interval = read_impl.microseconds_per_packet / 1000;
|
||||
samples = switch_samples_per_packet(member->conference->rate, interval);
|
||||
csamples = samples;
|
||||
tsamples = member->orig_read_codec->implementation->samples_per_packet;
|
||||
tsamples = member->orig_read_impl.samples_per_packet;
|
||||
flush_len = 0;
|
||||
low_count = 0;
|
||||
bytes = samples * 2;
|
||||
@@ -4434,9 +4435,9 @@ SWITCH_STANDARD_APP(conference_auto_function)
|
||||
|
||||
static int setup_media(conference_member_t *member, conference_obj_t *conference)
|
||||
{
|
||||
switch_codec_t *read_codec;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(member->session, &read_impl);
|
||||
|
||||
|
||||
switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE);
|
||||
|
||||
if (member->read_codec.implementation) {
|
||||
@@ -4447,22 +4448,22 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
|
||||
switch_resample_destroy(&member->read_resampler);
|
||||
}
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(member->session);
|
||||
member->orig_read_codec = read_codec;
|
||||
member->native_rate = read_codec->implementation->samples_per_second;
|
||||
|
||||
switch_core_session_get_read_impl(member->session, &member->orig_read_impl);
|
||||
member->native_rate = read_impl.samples_per_second;
|
||||
|
||||
/* 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_packet / 1000,
|
||||
NULL, read_impl.actual_samples_per_second, read_impl.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_packet / 1000);
|
||||
read_impl.actual_samples_per_second, read_impl.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_packet / 1000);
|
||||
read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000);
|
||||
|
||||
goto done;
|
||||
}
|
||||
@@ -4473,9 +4474,9 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
|
||||
member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
|
||||
}
|
||||
|
||||
if (read_codec->implementation->actual_samples_per_second != conference->rate) {
|
||||
if (read_impl.actual_samples_per_second != conference->rate) {
|
||||
if (switch_resample_create(&member->read_resampler,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
member->frame_size, conference->rate, member->frame_size, member->pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
|
||||
goto done;
|
||||
@@ -4499,14 +4500,14 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
|
||||
"L16",
|
||||
NULL,
|
||||
conference->rate,
|
||||
read_codec->implementation->microseconds_per_packet / 1000,
|
||||
read_impl.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_packet / 1000);
|
||||
conference->rate, read_impl.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_packet / 1000);
|
||||
conference->rate, read_impl.microseconds_per_packet / 1000);
|
||||
goto codec_done2;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
switch_status_t status;
|
||||
switch_size_t bytes;
|
||||
ls_control_packet_t control_packet;
|
||||
switch_codec_t codec = { 0 }, *read_codec, *orig_codec = NULL;
|
||||
switch_codec_t codec = { 0 };
|
||||
uint32_t flags = 0;
|
||||
const char *err;
|
||||
switch_rtp_t *rtp_session = NULL;
|
||||
@@ -78,6 +78,9 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
switch_port_t mcast_control_port = 6061;
|
||||
char *mcast_port_str = "34567";
|
||||
const char *esf_broadcast_ip = NULL, *var;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
|
||||
if (!switch_strlen_zero((char *) data)) {
|
||||
mydata = switch_core_session_strdup(session, data);
|
||||
@@ -120,8 +123,6 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
switch_channel_answer(channel);
|
||||
}
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
if (switch_socket_create(&socket, AF_INET, SOCK_DGRAM, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error 1\n");
|
||||
goto fail;
|
||||
@@ -144,7 +145,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (read_frame->packet && read_frame->packetlen && read_codec->implementation->ianacode == 0) {
|
||||
if (read_frame->packet && read_frame->packetlen && read_impl.ianacode == 0) {
|
||||
ready = SEND_TYPE_RAW;
|
||||
} else {
|
||||
ready = SEND_TYPE_RTP;
|
||||
@@ -152,7 +153,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
}
|
||||
|
||||
if (ready == SEND_TYPE_RTP) {
|
||||
if (read_codec->implementation->ianacode != 0) {
|
||||
if (read_impl.ianacode != 0) {
|
||||
if (switch_core_codec_init(&codec,
|
||||
"PCMU",
|
||||
NULL,
|
||||
@@ -160,9 +161,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
20,
|
||||
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
orig_codec = read_codec;
|
||||
read_codec = &codec;
|
||||
switch_core_session_set_read_codec(session, read_codec);
|
||||
switch_core_session_set_read_codec(session, &codec);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Activation Success\n");
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Fail\n");
|
||||
@@ -187,9 +186,9 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
rtp_port,
|
||||
mcast_ip,
|
||||
mcast_port,
|
||||
read_codec->implementation->ianacode,
|
||||
read_codec->implementation->samples_per_packet,
|
||||
read_codec->implementation->microseconds_per_packet,
|
||||
read_impl.ianacode,
|
||||
read_impl.samples_per_packet,
|
||||
read_impl.microseconds_per_packet,
|
||||
(switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session));
|
||||
|
||||
if (!switch_rtp_ready(rtp_session)) {
|
||||
@@ -242,8 +241,8 @@ SWITCH_STANDARD_APP(bcast_function)
|
||||
|
||||
fail:
|
||||
|
||||
if (orig_codec) {
|
||||
switch_core_session_set_read_codec(session, orig_codec);
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
if (codec.implementation) {
|
||||
switch_core_codec_destroy(&codec);
|
||||
}
|
||||
|
||||
|
||||
@@ -394,13 +394,12 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||
const char *tmp;
|
||||
|
||||
switch_channel_t *channel;
|
||||
|
||||
switch_codec_t *orig_read_codec = NULL;
|
||||
switch_codec_t read_codec = { 0 };
|
||||
switch_codec_t write_codec = { 0 };
|
||||
switch_frame_t *read_frame = { 0 };
|
||||
switch_frame_t write_frame = { 0 };
|
||||
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
int16_t *buf = NULL;
|
||||
|
||||
/* make sure we have a valid channel when starting the FAX application */
|
||||
@@ -575,13 +574,12 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||
* used internally by spandsp and FS will do the transcoding
|
||||
* from G.711 or any other original codec
|
||||
*/
|
||||
orig_read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
if (switch_core_codec_init(&read_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
orig_read_codec->implementation->samples_per_second,
|
||||
orig_read_codec->implementation->microseconds_per_packet / 1000,
|
||||
read_impl.samples_per_second,
|
||||
read_impl.microseconds_per_packet / 1000,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -596,8 +594,8 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||
if (switch_core_codec_init(&write_codec,
|
||||
"L16",
|
||||
NULL,
|
||||
orig_read_codec->implementation->samples_per_second,
|
||||
orig_read_codec->implementation->microseconds_per_packet / 1000,
|
||||
read_impl.samples_per_second,
|
||||
read_impl.microseconds_per_packet / 1000,
|
||||
1,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||
@@ -673,6 +671,8 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||
|
||||
/* restore the original codecs over the channel */
|
||||
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
|
||||
if (read_codec.implementation) {
|
||||
switch_core_codec_destroy(&read_codec);
|
||||
}
|
||||
@@ -681,9 +681,9 @@ void process_fax(switch_core_session_t *session, const char *data, application_m
|
||||
switch_core_codec_destroy(&write_codec);
|
||||
}
|
||||
|
||||
if (orig_read_codec) {
|
||||
switch_core_session_set_read_codec(session, orig_read_codec);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,9 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
int fd;
|
||||
switch_mutex_t *mutex = NULL;
|
||||
switch_codec_t codec, *read_codec, *vid_codec;
|
||||
switch_codec_t codec, *vid_codec;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
@@ -117,13 +119,11 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
|
||||
switch_channel_answer(channel);
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
if (switch_core_codec_init(&codec,
|
||||
"L16",
|
||||
NULL,
|
||||
read_codec->implementation->samples_per_second,
|
||||
read_codec->implementation->microseconds_per_packet / 1000,
|
||||
read_impl.samples_per_second,
|
||||
read_impl.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");
|
||||
@@ -145,8 +145,8 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
if (vid_codec->fmtp_in) {
|
||||
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_packet / 1000;
|
||||
h.audio_rate = read_impl.samples_per_second;
|
||||
h.audio_ptime = read_impl.microseconds_per_packet / 1000;
|
||||
|
||||
if (write(fd, &h, sizeof(h)) != sizeof(h)) {
|
||||
goto end;
|
||||
@@ -207,7 +207,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
|
||||
}
|
||||
}
|
||||
|
||||
switch_core_session_set_read_codec(session, read_codec);
|
||||
switch_core_session_set_read_codec(session, NULL);
|
||||
switch_core_codec_destroy(&codec);
|
||||
|
||||
}
|
||||
@@ -227,6 +227,8 @@ SWITCH_STANDARD_APP(play_fsv_function)
|
||||
uint32_t ts = 0, last = 0;
|
||||
switch_timer_t timer = { 0 };
|
||||
switch_payload_t pt = 0;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
aud_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
vid_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
|
||||
@@ -263,10 +265,8 @@ SWITCH_STANDARD_APP(play_fsv_function)
|
||||
vid_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE - 12;
|
||||
switch_set_flag((&vid_frame), SFF_RAW_RTP);
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
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) {
|
||||
if (switch_core_timer_init(&timer, "soft", read_impl.microseconds_per_packet / 1000,
|
||||
read_impl.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;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ SWITCH_STANDARD_APP(rss_function)
|
||||
struct rss_entry entries[TTS_MAX_ENTRIES] = { {0} };
|
||||
uint32_t i = 0;
|
||||
char *title_txt = "", *description_txt = "", *rights_txt = "";
|
||||
switch_codec_t speech_codec, *codec = switch_core_session_get_read_codec(session);
|
||||
switch_codec_t speech_codec;
|
||||
char *engine = TTS_DEFAULT_ENGINE;
|
||||
char *voice = TTS_DEFAULT_VOICE;
|
||||
char *timer_name = NULL;
|
||||
@@ -184,8 +184,9 @@ SWITCH_STANDARD_APP(rss_function)
|
||||
switch_input_args_t args = { 0 };
|
||||
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_packet / 1000;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
uint32_t rate, interval = read_impl.microseconds_per_packet / 1000;
|
||||
|
||||
if ((vcf = switch_channel_get_variable(channel, "rss_alt_config"))) {
|
||||
cf = vcf;
|
||||
@@ -253,8 +254,8 @@ SWITCH_STANDARD_APP(rss_function)
|
||||
return;
|
||||
}
|
||||
|
||||
if (codec) {
|
||||
rate = codec->implementation->actual_samples_per_second;
|
||||
if (switch_channel_media_ready(channel)) {
|
||||
rate = read_impl.actual_samples_per_second;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec Error!\n");
|
||||
return;
|
||||
|
||||
@@ -1042,9 +1042,9 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t
|
||||
char term;
|
||||
char input[10] = "", key_buf[80] = "";
|
||||
cc_t cc = { 0 };
|
||||
switch_codec_t *read_codec;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
if (exit_keys) {
|
||||
*key_pressed = '\0';
|
||||
@@ -1072,7 +1072,7 @@ static switch_status_t create_file(switch_core_session_t *session, vm_profile_t
|
||||
|
||||
switch_ivr_record_file(session, &fh, file_path, &args, profile->max_record_len);
|
||||
|
||||
if (limit && (*message_len = fh.sample_count / read_codec->implementation->actual_samples_per_second) < profile->min_record_len) {
|
||||
if (limit && (*message_len = fh.sample_count / read_impl.actual_samples_per_second) < profile->min_record_len) {
|
||||
if (unlink(file_path) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", file_path);
|
||||
}
|
||||
@@ -1216,7 +1216,6 @@ static void message_count(vm_profile_t *profile, const char *myid, const char *d
|
||||
static char *vm_merge_file(switch_core_session_t *session, vm_profile_t *profile, const char *announce, const char *orig)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
|
||||
switch_file_handle_t lrfh = { 0 }, *rfh = NULL, lfh = { 0 }, *fh = NULL;
|
||||
char *tmp_path;
|
||||
switch_uuid_t uuid;
|
||||
@@ -1225,19 +1224,21 @@ static char *vm_merge_file(switch_core_session_t *session, vm_profile_t *profile
|
||||
int16_t *abuf = NULL;
|
||||
switch_size_t olen = 0;
|
||||
int asis = 0;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(uuid_str, &uuid);
|
||||
|
||||
lfh.channels = read_codec->implementation->number_of_channels;
|
||||
lfh.native_rate = read_codec->implementation->actual_samples_per_second;
|
||||
lfh.channels = read_impl.number_of_channels;
|
||||
lfh.native_rate = read_impl.actual_samples_per_second;
|
||||
|
||||
tmp_path = switch_core_session_sprintf(session, "%s%smsg_%s.%s", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str, profile->file_ext);
|
||||
|
||||
if (switch_core_file_open(&lfh,
|
||||
tmp_path,
|
||||
lfh.channels,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file %s\n", tmp_path);
|
||||
goto end;
|
||||
@@ -1249,7 +1250,7 @@ static char *vm_merge_file(switch_core_session_t *session, vm_profile_t *profile
|
||||
if (switch_core_file_open(&lrfh,
|
||||
announce,
|
||||
lfh.channels,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file %s\n", announce);
|
||||
goto end;
|
||||
@@ -1286,7 +1287,7 @@ static char *vm_merge_file(switch_core_session_t *session, vm_profile_t *profile
|
||||
if (switch_core_file_open(&lrfh,
|
||||
orig,
|
||||
lfh.channels,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_impl.actual_samples_per_second,
|
||||
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file %s\n", orig);
|
||||
goto end;
|
||||
|
||||
@@ -1203,17 +1203,18 @@ void do_telecast(switch_stream_handle_t *stream)
|
||||
switch_mutex_t *mutex;
|
||||
switch_channel_t *channel = switch_core_session_get_channel(tsession);
|
||||
lame_global_flags *gfp = NULL;
|
||||
switch_codec_t *read_codec;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
switch_core_session_get_read_impl(tsession, &read_impl);
|
||||
|
||||
|
||||
|
||||
if (!(gfp = lame_init())) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n");
|
||||
goto end;
|
||||
}
|
||||
read_codec = switch_core_session_get_read_codec(tsession);
|
||||
|
||||
lame_set_num_channels(gfp, read_codec->implementation->number_of_channels);
|
||||
lame_set_in_samplerate(gfp, read_codec->implementation->actual_samples_per_second);
|
||||
lame_set_brate(gfp, 16 * (read_codec->implementation->actual_samples_per_second / 8000) * read_codec->implementation->number_of_channels);
|
||||
lame_set_num_channels(gfp, read_impl.number_of_channels);
|
||||
lame_set_in_samplerate(gfp, read_impl.actual_samples_per_second);
|
||||
lame_set_brate(gfp, 16 * (read_impl.actual_samples_per_second / 8000) * read_impl.number_of_channels);
|
||||
lame_set_mode(gfp, 3);
|
||||
lame_set_quality(gfp, 2);
|
||||
lame_set_errorf(gfp, log_error);
|
||||
|
||||
@@ -78,9 +78,11 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
JSObject *session_obj;
|
||||
struct teletone_obj *tto = NULL;
|
||||
struct js_session *jss = NULL;
|
||||
switch_codec_t *read_codec;
|
||||
switch_memory_pool_t *pool;
|
||||
char *timer_name = NULL;
|
||||
switch_codec_implementation_t read_impl = {0};
|
||||
|
||||
|
||||
|
||||
if (argc > 0) {
|
||||
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
|
||||
@@ -107,14 +109,14 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
read_codec = switch_core_session_get_read_codec(jss->session);
|
||||
switch_core_session_get_read_impl(jss->session, &read_impl);
|
||||
|
||||
if (switch_core_codec_init(&tto->codec,
|
||||
"L16",
|
||||
NULL,
|
||||
read_codec->implementation->actual_samples_per_second,
|
||||
read_codec->implementation->microseconds_per_packet / 1000,
|
||||
read_codec->implementation->number_of_channels,
|
||||
read_impl.actual_samples_per_second,
|
||||
read_impl.microseconds_per_packet / 1000,
|
||||
read_impl.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");
|
||||
} else {
|
||||
@@ -123,12 +125,12 @@ static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsv
|
||||
}
|
||||
|
||||
if (timer_name) {
|
||||
unsigned int ms = read_codec->implementation->microseconds_per_packet / 1000;
|
||||
unsigned int ms = read_impl.microseconds_per_packet / 1000;
|
||||
if (switch_core_timer_init(&tto->timer_base,
|
||||
timer_name,
|
||||
ms,
|
||||
(read_codec->implementation->samples_per_second / 50) *
|
||||
read_codec->implementation->number_of_channels, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
(read_impl.samples_per_second / 50) *
|
||||
read_impl.number_of_channels, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
tto->timer = &tto->timer_base;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Success %u\n", ms);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user