mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 16:15:04 +00:00
indent
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@416 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e528c4df33
commit
42383b1f15
@ -31,7 +31,8 @@
|
||||
*/
|
||||
#include <switch.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *err = NULL;
|
||||
switch_event *event;
|
||||
|
||||
@ -75,5 +76,3 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,8 @@ SWITCH_DECLARE(switch_status) switch_buffer_create(switch_memory_pool *pool, swi
|
||||
{
|
||||
switch_buffer *new_buffer;
|
||||
|
||||
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer))) && (new_buffer->data = switch_core_alloc(pool, max_len))) {
|
||||
if ((new_buffer = switch_core_alloc(pool, sizeof(switch_buffer)))
|
||||
&& (new_buffer->data = switch_core_alloc(pool, max_len))) {
|
||||
new_buffer->datalen = max_len;
|
||||
*buffer = new_buffer;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@ -137,4 +138,3 @@ SWITCH_DECLARE(int) switch_buffer_write(switch_buffer *buffer, void *data, size_
|
||||
//printf("i %d = %d\n", datalen, buffer->used);
|
||||
return (int) buffer->used;
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,7 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_new(switch_core_se
|
||||
char *caller_id_name,
|
||||
char *caller_id_number,
|
||||
char *network_addr,
|
||||
char *ani,
|
||||
char *ani2,
|
||||
char *destination_number)
|
||||
char *ani, char *ani2, char *destination_number)
|
||||
{
|
||||
|
||||
|
||||
@ -75,8 +73,8 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
|
||||
return profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix, switch_event *event)
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile *caller_profile, char *prefix,
|
||||
switch_event *event)
|
||||
{
|
||||
char header_name[1024];
|
||||
|
||||
@ -112,9 +110,7 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_core_session *session,
|
||||
char *extension_name,
|
||||
char *extension_number
|
||||
)
|
||||
char *extension_name, char *extension_number)
|
||||
{
|
||||
switch_caller_extension *caller_extension = NULL;
|
||||
|
||||
@ -130,8 +126,7 @@ SWITCH_DECLARE(switch_caller_extension *) switch_caller_extension_new(switch_cor
|
||||
|
||||
SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session *session,
|
||||
switch_caller_extension *caller_extension,
|
||||
char *application_name,
|
||||
char *application_data)
|
||||
char *application_name, char *application_data)
|
||||
{
|
||||
switch_caller_application *caller_application = NULL;
|
||||
|
||||
@ -151,6 +146,3 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(switch_core_session
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -71,7 +71,8 @@ SWITCH_DECLARE(switch_status) switch_channel_alloc(switch_channel **channel, swi
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode (switch_channel *channel, int freq, int bits, int channels, int ms, int kbps)
|
||||
SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode(switch_channel *channel, int freq, int bits, int channels,
|
||||
int ms, int kbps)
|
||||
{
|
||||
|
||||
assert(channel != NULL);
|
||||
@ -86,7 +87,8 @@ SWITCH_DECLARE(switch_status) switch_channel_set_raw_mode (switch_channel *chann
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode (switch_channel *channel, int *freq, int *bits, int *channels, int *ms, int *kbps)
|
||||
SWITCH_DECLARE(switch_status) switch_channel_get_raw_mode(switch_channel *channel, int *freq, int *bits, int *channels,
|
||||
int *ms, int *kbps)
|
||||
{
|
||||
if (freq) {
|
||||
*freq = channel->freq;
|
||||
@ -164,8 +166,7 @@ SWITCH_DECLARE(int) switch_channel_dequeue_dtmf(switch_channel *channel, char *d
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_channel_init(switch_channel *channel,
|
||||
switch_core_session *session,
|
||||
switch_channel_state state,
|
||||
switch_channel_flag flags)
|
||||
switch_channel_state state, switch_channel_flag flags)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->state = state;
|
||||
@ -381,11 +382,13 @@ default:
|
||||
|
||||
|
||||
if (ok) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name,
|
||||
state_names[last_state], state_names[state]);
|
||||
channel->state = state;
|
||||
switch_core_session_signal_state_change(channel->session);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name,
|
||||
state_names[last_state], state_names[state]);
|
||||
|
||||
//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
|
||||
if (channel->state < CS_HANGUP) {
|
||||
@ -407,7 +410,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
|
||||
originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
|
||||
originatee_caller_profile = switch_channel_get_originatee_caller_profile(channel);
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State",
|
||||
(char *) switch_channel_state_name(channel->state));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
|
||||
|
||||
@ -428,7 +432,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
|
||||
}
|
||||
|
||||
/* Index Variables */
|
||||
for (hi = switch_hash_first(switch_core_session_get_pool(channel->session), channel->variables); hi; hi = switch_hash_next(hi)) {
|
||||
for (hi = switch_hash_first(switch_core_session_get_pool(channel->session), channel->variables); hi;
|
||||
hi = switch_hash_next(hi)) {
|
||||
char buf[1024];
|
||||
switch_event_subclass *subclass;
|
||||
switch_hash_this(hi, &var, NULL, &val);
|
||||
@ -453,13 +458,15 @@ SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_caller_profile(switch
|
||||
return channel->caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
|
||||
SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel *channel,
|
||||
switch_caller_profile *caller_profile)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->originator_caller_profile = caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel, switch_caller_profile *caller_profile)
|
||||
SWITCH_DECLARE(void) switch_channel_set_originatee_caller_profile(switch_channel *channel,
|
||||
switch_caller_profile *caller_profile)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->originatee_caller_profile = caller_profile;
|
||||
@ -477,7 +484,8 @@ SWITCH_DECLARE(switch_caller_profile *) switch_channel_get_originatee_caller_pro
|
||||
return channel->originatee_caller_profile;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel, const struct switch_event_handler_table *event_handlers)
|
||||
SWITCH_DECLARE(void) switch_channel_set_event_handlers(switch_channel *channel,
|
||||
const struct switch_event_handler_table *event_handlers)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->event_handlers = event_handlers;
|
||||
@ -489,7 +497,8 @@ SWITCH_DECLARE(const struct switch_event_handler_table *) switch_channel_get_eve
|
||||
return channel->event_handlers;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel, switch_caller_extension *caller_extension)
|
||||
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel *channel,
|
||||
switch_caller_extension *caller_extension)
|
||||
{
|
||||
assert(channel != NULL);
|
||||
channel->caller_extension = caller_extension;
|
||||
|
@ -154,6 +154,3 @@ SWITCH_DECLARE(int) switch_config_next_pair(switch_config *cfg, char **var, char
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -54,15 +54,10 @@ static int switch_console_process(char *cmd)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
"\n"
|
||||
"Valid Commands:\n\n"
|
||||
"version\n"
|
||||
"help - umm yeah..\n"
|
||||
"%sshutdown - stop the program\n\n",
|
||||
perlhelp
|
||||
);
|
||||
"version\n" "help - umm yeah..\n" "%sshutdown - stop the program\n\n", perlhelp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef EMBED_PERL
|
||||
if (!strncmp(cmd, "perl ", 5)) {
|
||||
cmd += 5;
|
||||
@ -79,14 +74,16 @@ static int switch_console_process(char *cmd)
|
||||
*arg++ = '\0';
|
||||
}
|
||||
if (switch_api_execute(cmd, arg, retbuf, sizeof(retbuf)) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "", retbuf);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "API CALL [%s(%s)] output:\n%s\n", cmd, arg ? arg : "",
|
||||
retbuf);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Unknown Command: %s\n", cmd);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line, char *fmt, ...)
|
||||
SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *file, const char *func, int line,
|
||||
char *fmt, ...)
|
||||
{
|
||||
char *data;
|
||||
int ret = 0;
|
||||
|
@ -221,7 +221,10 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_se
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms, int channels, switch_codec_flag flags, const switch_codec_settings *codec_settings, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *codec_name, int rate, int ms,
|
||||
int channels, switch_codec_flag flags,
|
||||
const switch_codec_settings *codec_settings,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
const switch_codec_interface *codec_interface;
|
||||
const switch_codec_implementation *iptr, *implementation = NULL;
|
||||
@ -263,7 +266,8 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s Exists but not then desired implementation.\n", codec_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s Exists but not then desired implementation.\n",
|
||||
codec_name);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_NOTIMPL;
|
||||
@ -276,9 +280,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
size_t *encoded_data_len, int *encoded_rate, unsigned int *flag)
|
||||
{
|
||||
assert(codec != NULL);
|
||||
assert(encoded_data != NULL);
|
||||
@ -299,11 +301,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||
other_codec,
|
||||
decoded_data,
|
||||
decoded_data_len,
|
||||
decoded_rate,
|
||||
encoded_data,
|
||||
encoded_data_len,
|
||||
encoded_rate,
|
||||
flag);
|
||||
decoded_rate, encoded_data, encoded_data_len, encoded_rate, flag);
|
||||
|
||||
}
|
||||
|
||||
@ -313,9 +311,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
size_t *decoded_data_len, int *decoded_rate, unsigned int *flag)
|
||||
{
|
||||
|
||||
assert(codec != NULL);
|
||||
@ -337,11 +333,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||
other_codec,
|
||||
encoded_data,
|
||||
encoded_data_len,
|
||||
encoded_rate,
|
||||
decoded_data,
|
||||
decoded_data_len,
|
||||
decoded_rate,
|
||||
flag);
|
||||
encoded_rate, decoded_data, decoded_data_len, decoded_rate, flag);
|
||||
|
||||
}
|
||||
|
||||
@ -363,7 +355,8 @@ SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec)
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char *file_path, unsigned int flags,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
char *ext;
|
||||
switch_status status;
|
||||
@ -408,7 +401,8 @@ SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, voi
|
||||
return fh->file_interface->file_write(fh, data, (unsigned int *) len);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples, int whence)
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples,
|
||||
int whence)
|
||||
{
|
||||
return fh->file_interface->file_seek(fh, cur_pos, samples, whence);
|
||||
}
|
||||
@ -419,7 +413,8 @@ SWITCH_DECLARE(switch_status) switch_core_file_close(switch_file_handle *fh)
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_core_timer_init(switch_timer *timer, char *timer_name, int interval, int samples,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
switch_timer_interface *timer_interface;
|
||||
switch_status status;
|
||||
@ -533,7 +528,8 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *
|
||||
}
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session, switch_core_thread_session *thread_session, int stream_id)
|
||||
SWITCH_DECLARE(void) switch_core_service_session(switch_core_session *session,
|
||||
switch_core_thread_session *thread_session, int stream_id)
|
||||
{
|
||||
thread_session->running = 1;
|
||||
thread_session->objs[0] = session;
|
||||
@ -581,7 +577,8 @@ SWITCH_DECLARE(char *) switch_core_permenant_strdup(char *todup)
|
||||
|
||||
assert(runtime.memory_pool != NULL);
|
||||
|
||||
if (!todup) return NULL;
|
||||
if (!todup)
|
||||
return NULL;
|
||||
|
||||
len = strlen(todup) + 1;
|
||||
if (todup && (duped = apr_palloc(runtime.memory_pool, len))) {
|
||||
@ -598,7 +595,8 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session,
|
||||
assert(session != NULL);
|
||||
assert(session->pool != NULL);
|
||||
|
||||
if (!todup) return NULL;
|
||||
if (!todup)
|
||||
return NULL;
|
||||
|
||||
len = strlen(todup) + 1;
|
||||
|
||||
@ -616,7 +614,8 @@ SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup)
|
||||
assert(pool != NULL);
|
||||
assert(todup != NULL);
|
||||
|
||||
if (!todup) return NULL;
|
||||
if (!todup)
|
||||
return NULL;
|
||||
len = strlen(todup) + 1;
|
||||
|
||||
if (todup && (duped = apr_palloc(pool, len))) {
|
||||
@ -671,7 +670,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_s
|
||||
}
|
||||
|
||||
if (endpoint_interface->io_routines->outgoing_channel) {
|
||||
if ((status = endpoint_interface->io_routines->outgoing_channel(session, caller_profile, new_session)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
endpoint_interface->io_routines->outgoing_channel(session, caller_profile,
|
||||
new_session)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->outgoing_channel(session, caller_profile, *new_session)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@ -729,14 +730,16 @@ SWITCH_DECLARE(switch_status) switch_core_session_answer_channel(switch_core_ses
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session, switch_core_session_message *message)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_session *session,
|
||||
switch_core_session_message *message)
|
||||
{
|
||||
struct switch_io_event_hook_receive_message *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
assert(session != NULL);
|
||||
if (session->endpoint_interface->io_routines->receive_message) {
|
||||
if ((status = session->endpoint_interface->io_routines->receive_message(session, message)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->receive_message(session, message)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.receive_message; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->receive_message(session, message)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@ -750,7 +753,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_receive_message(switch_core_se
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame, int timeout, int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session *session, switch_frame **frame,
|
||||
int timeout, int stream_id)
|
||||
{
|
||||
struct switch_io_event_hook_read_frame *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
@ -764,7 +768,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
SWITCH_IO_FLAG_NOOP,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.read_frame; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
ptr->read_frame(session, frame, timeout, SWITCH_IO_FLAG_NOOP,
|
||||
stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -776,7 +782,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
}
|
||||
|
||||
/* if you think this code is redundant.... too bad! I like to understand what I'm doing */
|
||||
if ((session->read_codec && (*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
|
||||
if ((session->read_codec && (*frame)->codec
|
||||
&& session->read_codec->implementation != (*frame)->codec->implementation)) {
|
||||
need_codec = TRUE;
|
||||
}
|
||||
|
||||
@ -800,9 +807,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
read_frame->datalen,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->raw_read_frame.data,
|
||||
&session->raw_read_frame.datalen,
|
||||
&session->raw_read_frame.rate,
|
||||
&flag);
|
||||
&session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
@ -811,8 +816,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
read_frame->codec->implementation->samples_per_second,
|
||||
read_frame->codec->implementation->bytes_per_frame * 20,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->read_codec->implementation->bytes_per_frame * 20,
|
||||
session->pool);
|
||||
session->read_codec->implementation->bytes_per_frame * 20, session->pool);
|
||||
}
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
read_frame = &session->raw_read_frame;
|
||||
@ -821,7 +825,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
@ -829,13 +834,12 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
if (session->read_resampler) {
|
||||
short *data = read_frame->data;
|
||||
|
||||
session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int)read_frame->datalen / 2 );
|
||||
session->read_resampler->to_len = switch_resample_process(session->read_resampler,
|
||||
session->read_resampler->from,
|
||||
session->read_resampler->from_len,
|
||||
session->read_resampler->to,
|
||||
(int)session->read_resampler->to_size,
|
||||
0);
|
||||
session->read_resampler->from_len =
|
||||
switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
|
||||
session->read_resampler->to_len =
|
||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||
session->read_resampler->from_len, session->read_resampler->to,
|
||||
(int) session->read_resampler->to_size, 0);
|
||||
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
||||
read_frame->samples = session->read_resampler->to_len;
|
||||
read_frame->datalen = session->read_resampler->to_len * 2;
|
||||
@ -865,7 +869,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
} else {
|
||||
session->raw_read_frame.datalen = switch_buffer_read(session->raw_read_buffer,
|
||||
session->raw_read_frame.data,
|
||||
session->read_codec->implementation->bytes_per_frame);
|
||||
session->read_codec->implementation->
|
||||
bytes_per_frame);
|
||||
session->raw_read_frame.rate = session->read_codec->implementation->samples_per_second;
|
||||
enc_frame = &session->raw_read_frame;
|
||||
}
|
||||
@ -877,8 +882,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
(*frame)->codec->implementation->samples_per_second,
|
||||
session->enc_read_frame.data,
|
||||
&session->enc_read_frame.datalen,
|
||||
&session->enc_read_frame.rate,
|
||||
&flag);
|
||||
&session->enc_read_frame.rate, &flag);
|
||||
|
||||
|
||||
switch (status) {
|
||||
@ -892,7 +896,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
*frame = NULL;
|
||||
status = SWITCH_STATUS_GENERR;
|
||||
break;
|
||||
@ -904,12 +909,16 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags, int stream_id) {
|
||||
static switch_status perform_write(switch_core_session *session, switch_frame *frame, int timeout, switch_io_flag flags,
|
||||
int stream_id)
|
||||
{
|
||||
struct switch_io_event_hook_write_frame *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->write_frame) {
|
||||
if ((status = session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->write_frame(session, frame, timeout, flags,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.write_frame; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->write_frame(session, frame, timeout, flags, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@ -920,7 +929,8 @@ static switch_status perform_write(switch_core_session *session, switch_frame *f
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame, int timeout, int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_session *session, switch_frame *frame,
|
||||
int timeout, int stream_id)
|
||||
{
|
||||
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
@ -950,9 +960,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
frame->datalen,
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->raw_write_frame.data,
|
||||
&session->raw_write_frame.datalen,
|
||||
&session->raw_write_frame.rate,
|
||||
&flag);
|
||||
&session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
@ -974,7 +982,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n",
|
||||
frame->codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
@ -982,13 +991,12 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
if (session->write_resampler) {
|
||||
short *data = write_frame->data;
|
||||
|
||||
session->write_resampler->from_len = switch_short_to_float(data, session->write_resampler->from, (int)write_frame->datalen / 2);
|
||||
session->write_resampler->to_len = switch_resample_process(session->write_resampler,
|
||||
session->write_resampler->from,
|
||||
session->write_resampler->from_len,
|
||||
session->write_resampler->to,
|
||||
(int)session->write_resampler->to_size,
|
||||
0);
|
||||
session->write_resampler->from_len =
|
||||
switch_short_to_float(data, session->write_resampler->from, (int) write_frame->datalen / 2);
|
||||
session->write_resampler->to_len =
|
||||
switch_resample_process(session->write_resampler, session->write_resampler->from,
|
||||
session->write_resampler->from_len, session->write_resampler->to,
|
||||
(int) session->write_resampler->to_size, 0);
|
||||
switch_float_to_short(session->write_resampler->to, data, write_frame->datalen * 2);
|
||||
write_frame->samples = session->write_resampler->to_len;
|
||||
write_frame->datalen = session->write_resampler->to_len * 2;
|
||||
@ -1003,9 +1011,10 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
|
||||
"Engaging Write Buffer at %d bytes to accomidate %d->%d\n",
|
||||
bytes,
|
||||
write_frame->datalen,
|
||||
session->write_codec->implementation->bytes_per_frame);
|
||||
if ((status = switch_buffer_create(session->pool, &session->raw_write_buffer, bytes)) != SWITCH_STATUS_SUCCESS) {
|
||||
write_frame->datalen, session->write_codec->implementation->bytes_per_frame);
|
||||
if ((status =
|
||||
switch_buffer_create(session->pool, &session->raw_write_buffer,
|
||||
bytes)) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Write Buffer Failed!\n");
|
||||
return status;
|
||||
}
|
||||
@ -1026,8 +1035,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
&session->enc_write_frame.rate, &flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
@ -1040,7 +1048,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
@ -1058,9 +1067,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
int x;
|
||||
for (x = 0; x < frames; x++) {
|
||||
if ((session->raw_write_frame.datalen =
|
||||
switch_buffer_read(session->raw_write_buffer,
|
||||
session->raw_write_frame.data,
|
||||
bytes))) {
|
||||
switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes))) {
|
||||
|
||||
enc_frame = &session->raw_write_frame;
|
||||
session->raw_write_frame.rate = session->write_codec->implementation->samples_per_second;
|
||||
@ -1072,8 +1079,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
frame->codec->implementation->samples_per_second,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
&session->enc_write_frame.rate, &flag);
|
||||
|
||||
|
||||
|
||||
@ -1084,9 +1090,10 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
status = switch_resample_create(&session->read_resampler,
|
||||
frame->codec->implementation->samples_per_second,
|
||||
frame->codec->implementation->bytes_per_frame * 20,
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->write_codec->implementation->bytes_per_frame * 20,
|
||||
session->pool);
|
||||
session->write_codec->implementation->
|
||||
samples_per_second,
|
||||
session->write_codec->implementation->
|
||||
bytes_per_frame * 20, session->pool);
|
||||
}
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
@ -1097,7 +1104,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n",
|
||||
session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
@ -1108,13 +1116,13 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
|
||||
session->read_resampler->from_len = switch_short_to_float(data,
|
||||
session->read_resampler->from,
|
||||
(int)write_frame->datalen / 2);
|
||||
session->read_resampler->to_len = switch_resample_process(session->read_resampler,
|
||||
session->read_resampler->from,
|
||||
(int) write_frame->datalen /
|
||||
2);
|
||||
session->read_resampler->to_len =
|
||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||
session->read_resampler->from_len,
|
||||
session->read_resampler->to,
|
||||
(int)session->read_resampler->to_size,
|
||||
0);
|
||||
(int) session->read_resampler->to_size, 0);
|
||||
switch_float_to_short(session->read_resampler->to, data, write_frame->datalen * 2);
|
||||
write_frame->samples = session->read_resampler->to_len;
|
||||
write_frame->datalen = session->read_resampler->to_len * 2;
|
||||
@ -1158,7 +1166,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_sessi
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->waitfor_read) {
|
||||
if ((status = session->endpoint_interface->io_routines->waitfor_read(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->waitfor_read(session, timeout,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.waitfor_read; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->waitfor_read(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@ -1171,13 +1181,16 @@ SWITCH_DECLARE(switch_status) switch_core_session_waitfor_read(switch_core_sessi
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout, int stream_id)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_waitfor_write(switch_core_session *session, int timeout,
|
||||
int stream_id)
|
||||
{
|
||||
struct switch_io_event_hook_waitfor_write *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
|
||||
if (session->endpoint_interface->io_routines->waitfor_write) {
|
||||
if ((status = session->endpoint_interface->io_routines->waitfor_write(session, timeout, stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
if ((status =
|
||||
session->endpoint_interface->io_routines->waitfor_write(session, timeout,
|
||||
stream_id)) == SWITCH_STATUS_SUCCESS) {
|
||||
for (ptr = session->event_hooks.waitfor_write; ptr; ptr = ptr->next) {
|
||||
if ((status = ptr->waitfor_write(session, timeout, stream_id)) != SWITCH_STATUS_SUCCESS) {
|
||||
break;
|
||||
@ -1208,7 +1221,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_send_dtmf(switch_core_session
|
||||
return status;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session, switch_outgoing_channel_hook outgoing_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch_core_session *session,
|
||||
switch_outgoing_channel_hook outgoing_channel)
|
||||
{
|
||||
switch_io_event_hook_outgoing_channel *hook, *ptr;
|
||||
|
||||
@ -1229,7 +1243,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_outgoing(switch
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session, switch_answer_channel_hook answer_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(switch_core_session *session,
|
||||
switch_answer_channel_hook
|
||||
answer_channel)
|
||||
{
|
||||
switch_io_event_hook_answer_channel *hook, *ptr;
|
||||
|
||||
@ -1251,7 +1267,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_answer_channel(
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session, switch_read_frame_hook read_frame)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(switch_core_session *session,
|
||||
switch_read_frame_hook read_frame)
|
||||
{
|
||||
switch_io_event_hook_read_frame *hook, *ptr;
|
||||
|
||||
@ -1273,7 +1290,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_read_frame(swit
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session, switch_write_frame_hook write_frame)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(switch_core_session *session,
|
||||
switch_write_frame_hook write_frame)
|
||||
{
|
||||
switch_io_event_hook_write_frame *hook, *ptr;
|
||||
|
||||
@ -1295,7 +1313,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_write_frame(swi
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session, switch_kill_channel_hook kill_channel)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(switch_core_session *session,
|
||||
switch_kill_channel_hook kill_channel)
|
||||
{
|
||||
switch_io_event_hook_kill_channel *hook, *ptr;
|
||||
|
||||
@ -1317,7 +1336,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_kill_channel(sw
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session, switch_waitfor_read_hook waitfor_read)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(switch_core_session *session,
|
||||
switch_waitfor_read_hook waitfor_read)
|
||||
{
|
||||
switch_io_event_hook_waitfor_read *hook, *ptr;
|
||||
|
||||
@ -1339,7 +1359,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_read(sw
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session, switch_waitfor_write_hook waitfor_write)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(switch_core_session *session,
|
||||
switch_waitfor_write_hook waitfor_write)
|
||||
{
|
||||
switch_io_event_hook_waitfor_write *hook, *ptr;
|
||||
|
||||
@ -1362,7 +1383,8 @@ SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_waitfor_write(s
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session, switch_send_dtmf_hook send_dtmf)
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_add_event_hook_send_dtmf(switch_core_session *session,
|
||||
switch_send_dtmf_hook send_dtmf)
|
||||
{
|
||||
switch_io_event_hook_send_dtmf *hook, *ptr;
|
||||
|
||||
@ -1459,16 +1481,21 @@ static void switch_core_standard_on_execute(switch_core_session *session)
|
||||
}
|
||||
|
||||
while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Execute %s(%s)\n", extension->current_application->application_name,
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Execute %s(%s)\n",
|
||||
extension->current_application->application_name,
|
||||
extension->current_application->application_data);
|
||||
if (!(application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Application %s\n", extension->current_application->application_name);
|
||||
if (!
|
||||
(application_interface =
|
||||
switch_loadable_module_get_application_interface(extension->current_application->application_name))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Application %s\n",
|
||||
extension->current_application->application_name);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!application_interface->application_function) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Function for %s\n", extension->current_application->application_name);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Function for %s\n",
|
||||
extension->current_application->application_name);
|
||||
switch_channel_set_state(session->channel, CS_HANGUP);
|
||||
return;
|
||||
}
|
||||
@ -1741,12 +1768,7 @@ SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void
|
||||
}
|
||||
ts->objs[0] = obj;
|
||||
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
func,
|
||||
ts,
|
||||
pool
|
||||
);
|
||||
switch_thread_create(&thread, thd_attr, func, ts, pool);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1781,30 +1803,21 @@ SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *sess
|
||||
switch_threadattr_create(&thd_attr, session->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
if (switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
switch_core_session_thread,
|
||||
session,
|
||||
session->pool
|
||||
) != APR_SUCCESS) {
|
||||
if (switch_thread_create(&thread, thd_attr, switch_core_session_thread, session, session->pool) != APR_SUCCESS) {
|
||||
switch_core_session_destroy(&session);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, switch_thread_start_t func, void *obj)
|
||||
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *session, switch_thread_start_t func,
|
||||
void *obj)
|
||||
{
|
||||
switch_thread *thread;
|
||||
switch_threadattr_t *thd_attr = NULL;
|
||||
switch_threadattr_create(&thd_attr, session->pool);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
func,
|
||||
obj,
|
||||
session->pool
|
||||
);
|
||||
switch_thread_create(&thread, thd_attr, func, obj, session->pool);
|
||||
|
||||
}
|
||||
|
||||
@ -1820,7 +1833,8 @@ SWITCH_DECLARE(void *) switch_core_alloc(switch_memory_pool *pool, size_t memory
|
||||
return ptr;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_endpoint_interface *endpoint_interface,
|
||||
switch_memory_pool *pool)
|
||||
{
|
||||
switch_memory_pool *usepool;
|
||||
switch_core_session *session;
|
||||
@ -1936,7 +1950,8 @@ SWITCH_DECLARE(switch_status) switch_core_init(void)
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error Opening DB!\n");
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Opening DB\n");
|
||||
if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
|
||||
if (switch_event_bind("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, core_event_handler, NULL) !=
|
||||
SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind event handler!\n");
|
||||
}
|
||||
}
|
||||
@ -2000,4 +2015,3 @@ SWITCH_DECLARE(switch_status) switch_core_destroy(void)
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ static void *locked_dup(char *str)
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
#define ALLOC(size) locked_alloc(size)
|
||||
#define DUP(str) locked_dup(str)
|
||||
#endif
|
||||
@ -267,12 +268,7 @@ SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
|
||||
switch_mutex_init(&BLOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
|
||||
switch_mutex_init(&POOL_LOCK, SWITCH_MUTEX_NESTED, RUNTIME_POOL);
|
||||
switch_core_hash_init(&CUSTOM_HASH, RUNTIME_POOL);
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
switch_event_thread,
|
||||
NULL,
|
||||
RUNTIME_POOL
|
||||
);
|
||||
switch_thread_create(&thread, thd_attr, switch_event_thread, NULL, RUNTIME_POOL);
|
||||
|
||||
while (!THREAD_RUNNING) {
|
||||
switch_yield(1000);
|
||||
@ -281,7 +277,8 @@ SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id, char *subclass_name)
|
||||
SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event, switch_event_t event_id,
|
||||
char *subclass_name)
|
||||
{
|
||||
|
||||
if (event_id != SWITCH_EVENT_CUSTOM && subclass_name) {
|
||||
@ -291,7 +288,6 @@ SWITCH_DECLARE(switch_status) switch_event_create_subclass(switch_event **event,
|
||||
if (!(*event = ALLOC(sizeof(switch_event)))) {
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
#ifdef MALLOC_EVENTS
|
||||
memset(*event, 0, sizeof(switch_event));
|
||||
#endif
|
||||
@ -318,7 +314,8 @@ SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name, char *fmt, ...)
|
||||
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name,
|
||||
char *fmt, ...)
|
||||
{
|
||||
int ret = 0;
|
||||
char data[2048];
|
||||
@ -489,7 +486,8 @@ SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event, void *user_data)
|
||||
SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func, int line, switch_event **event,
|
||||
void *user_data)
|
||||
{
|
||||
|
||||
switch_time_exp_t tm;
|
||||
@ -535,7 +533,8 @@ SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name, switch_event_callback_t callback, void *user_data)
|
||||
SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event, char *subclass_name,
|
||||
switch_event_callback_t callback, void *user_data)
|
||||
{
|
||||
switch_event_node *event_node;
|
||||
switch_event_subclass *subclass = NULL;
|
||||
@ -575,4 +574,3 @@ SWITCH_DECLARE(switch_status) switch_event_bind(char *id, switch_event_t event,
|
||||
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,8 @@ static void *switch_loadable_module_exec(switch_thread *thread, void *obj)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool, switch_loadable_module **new_module)
|
||||
static switch_status switch_loadable_module_load_file(char *filename, switch_memory_pool *pool,
|
||||
switch_loadable_module **new_module)
|
||||
{
|
||||
switch_loadable_module *module = NULL;
|
||||
apr_dso_handle_t *dso = NULL;
|
||||
@ -250,9 +251,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
const switch_endpoint_interface *ptr;
|
||||
for (ptr = new_module->interface->endpoint_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Endpoint '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.endpoint_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.endpoint_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,13 +265,10 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
"Adding Codec '%s' (%s) %dkhz %dms\n",
|
||||
ptr->iananame,
|
||||
ptr->interface_name,
|
||||
impl->samples_per_second,
|
||||
impl->microseconds_per_frame / 1000);
|
||||
impl->samples_per_second, impl->microseconds_per_frame / 1000);
|
||||
}
|
||||
|
||||
switch_core_hash_insert(loadable_modules.codec_hash,
|
||||
(char *) ptr->iananame,
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.codec_hash, (char *) ptr->iananame, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,9 +277,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
|
||||
for (ptr = new_module->interface->dialplan_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Dialplan '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.dialplan_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.dialplan_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,9 +286,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
|
||||
for (ptr = new_module->interface->timer_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Timer '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.timer_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.timer_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,8 +296,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
for (ptr = new_module->interface->application_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding Application '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.application_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
(char *) ptr->interface_name, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,9 +305,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
|
||||
for (ptr = new_module->interface->api_interface; ptr; ptr = ptr->next) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding API Function '%s'\n", ptr->interface_name);
|
||||
switch_core_hash_insert(loadable_modules.api_hash,
|
||||
(char *) ptr->interface_name,
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.api_hash, (char *) ptr->interface_name, (void *) ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,9 +316,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
||||
int i;
|
||||
for (i = 0; ptr->extens[i]; i++) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Adding File Format '%s'\n", ptr->extens[i]);
|
||||
switch_core_hash_insert(loadable_modules.file_hash,
|
||||
(char *) ptr->extens[i],
|
||||
(void *) ptr);
|
||||
switch_core_hash_insert(loadable_modules.file_hash, (char *) ptr->extens[i], (void *) ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -397,7 +384,8 @@ SWITCH_DECLARE(switch_file_interface *) switch_loadable_module_get_file_interfac
|
||||
return switch_core_hash_find(loadable_modules.file_hash, name);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array, int arraylen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool, switch_codec_interface **array,
|
||||
int arraylen)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
void *val;
|
||||
@ -415,7 +403,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool *pool,
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array, int arraylen, char **prefs, int preflen)
|
||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_memory_pool *pool, switch_codec_interface **array,
|
||||
int arraylen, char **prefs, int preflen)
|
||||
{
|
||||
int x, i = 0;
|
||||
switch_codec_interface *codec_interface;
|
||||
|
@ -31,9 +31,7 @@
|
||||
*/
|
||||
#include <switch_mutex.h>
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock,
|
||||
switch_lock_flag flags,
|
||||
switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock, switch_lock_flag flags, switch_memory_pool *pool)
|
||||
{
|
||||
|
||||
return (apr_thread_mutex_create(lock, flags, pool) == APR_SUCCESS) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
|
||||
@ -58,5 +56,3 @@ SWITCH_DECLARE(switch_status) switch_mutex_trylock(switch_mutex_t *lock)
|
||||
{
|
||||
return apr_thread_mutex_trylock(lock);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,9 +49,7 @@
|
||||
SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
|
||||
int from_rate,
|
||||
size_t from_size,
|
||||
int to_rate,
|
||||
size_t to_size,
|
||||
switch_memory_pool *pool)
|
||||
int to_rate, size_t to_size, switch_memory_pool *pool)
|
||||
{
|
||||
switch_audio_resampler *resampler;
|
||||
|
||||
@ -64,7 +62,8 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
||||
resampler->factor = ((double) resampler->to_rate / (double) resampler->from_rate);
|
||||
|
||||
resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate, resampler->factor);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Resampler %d->%d %f\n", resampler->from_rate,
|
||||
resampler->to_rate, resampler->factor);
|
||||
resampler->from_size = from_size;
|
||||
resampler->from = (float *) switch_core_alloc(pool, resampler->from_size);
|
||||
resampler->to_size = to_size;
|
||||
@ -75,14 +74,16 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last)
|
||||
SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst,
|
||||
int dstlen, int last)
|
||||
{
|
||||
int o = 0, srcused = 0, srcpos = 0, out = 0;
|
||||
|
||||
for (;;) {
|
||||
int srcBlock = MIN(srclen - srcpos, srclen);
|
||||
int lastFlag = (last && (srcBlock == srclen - srcpos));
|
||||
o = resample_process(resampler->resampler, resampler->factor, &src[srcpos], srcBlock, lastFlag, &srcused, &dst[out], dstlen-out);
|
||||
o = resample_process(resampler->resampler, resampler->factor, &src[srcpos], srcBlock, lastFlag, &srcused,
|
||||
&dst[out], dstlen - out);
|
||||
//printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
|
||||
|
||||
srcpos += srcused;
|
||||
@ -113,8 +114,10 @@ SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len)
|
||||
} else {
|
||||
s[i] = (short) (ft - 0.5);
|
||||
}
|
||||
if ((float)s[i] > MAXSAMPLE) s[i] = (short)MAXSAMPLE;
|
||||
if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;
|
||||
if ((float) s[i] > MAXSAMPLE)
|
||||
s[i] = (short) MAXSAMPLE;
|
||||
if (s[i] < (short) -MAXSAMPLE)
|
||||
s[i] = (short) -MAXSAMPLE;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@ -130,8 +133,10 @@ SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)
|
||||
for (i = 1; i < len; i += 2) {
|
||||
f[(int) (i / 2)] = (float) (((c[i]) * 0x100) + c[i - 1]);
|
||||
f[(int) (i / 2)] /= NORMFACT;
|
||||
if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;
|
||||
if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;
|
||||
if (f[(int) (i / 2)] > MAXSAMPLE)
|
||||
f[(int) (i / 2)] = MAXSAMPLE;
|
||||
if (f[(int) (i / 2)] < -MAXSAMPLE)
|
||||
f[(int) (i / 2)] = -MAXSAMPLE;
|
||||
}
|
||||
return len / 2;
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ SWITCH_DECLARE(char *) switch_cut_path(char *in)
|
||||
return ret;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool)
|
||||
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock,
|
||||
unsigned int flags, switch_memory_pool *pool)
|
||||
{
|
||||
switch_pollset_t *pollset;
|
||||
switch_status status;
|
||||
|
Loading…
x
Reference in New Issue
Block a user