mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
cleanup and formating
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@261 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -146,7 +146,7 @@ SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename)
|
||||
{
|
||||
switch_core_db *db;
|
||||
char path[1024];
|
||||
|
||||
|
||||
db_pick_path(filename, path, sizeof(path));
|
||||
if (switch_core_db_open(path, &db)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "SQL ERR [%s]\n", switch_core_db_errmsg(db));
|
||||
@@ -161,13 +161,13 @@ SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel)
|
||||
FILE *handle = stdout;
|
||||
|
||||
switch (channel) {
|
||||
case SWITCH_CHANNEL_ID_CONSOLE:
|
||||
case SWITCH_CHANNEL_ID_CONSOLE_CLEAN:
|
||||
handle = runtime.console;
|
||||
break;
|
||||
default:
|
||||
handle = stdout;
|
||||
break;
|
||||
case SWITCH_CHANNEL_ID_CONSOLE:
|
||||
case SWITCH_CHANNEL_ID_CONSOLE_CLEAN:
|
||||
handle = runtime.console;
|
||||
break;
|
||||
default:
|
||||
handle = stdout;
|
||||
break;
|
||||
}
|
||||
|
||||
return handle;
|
||||
@@ -225,8 +225,8 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
||||
if ((!rate || rate == iptr->samples_per_second) &&
|
||||
(!ms || ms == (iptr->microseconds_per_frame / 1000)) &&
|
||||
(!channels || channels == iptr->number_of_channels)) {
|
||||
implementation = iptr;
|
||||
break;
|
||||
implementation = iptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,14 +256,14 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
switch_codec *other_codec,
|
||||
void *decoded_data,
|
||||
size_t decoded_data_len,
|
||||
int decoded_rate,
|
||||
void *encoded_data,
|
||||
size_t *encoded_data_len,
|
||||
int *encoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
assert(codec != NULL);
|
||||
assert(encoded_data != NULL);
|
||||
@@ -283,14 +283,14 @@ SWITCH_DECLARE(switch_status) switch_core_codec_encode(switch_codec *codec,
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_codec_decode(switch_codec *codec,
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
switch_codec *other_codec,
|
||||
void *encoded_data,
|
||||
size_t encoded_data_len,
|
||||
int encoded_rate,
|
||||
void *decoded_data,
|
||||
size_t *decoded_data_len,
|
||||
int *decoded_rate,
|
||||
unsigned int *flag)
|
||||
{
|
||||
assert(codec != NULL);
|
||||
assert(encoded_data != NULL);
|
||||
@@ -335,7 +335,7 @@ SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char
|
||||
memset(fh, 0, sizeof(*fh));
|
||||
|
||||
if (!(ext = strrchr(file_path, '.'))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Format\n");
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Format\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
ext++;
|
||||
@@ -344,15 +344,15 @@ SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "invalid file format [%s]!\n", ext);
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
|
||||
fh->flags = flags;
|
||||
if (pool) {
|
||||
fh->memory_pool = pool;
|
||||
} else {
|
||||
if ((status = switch_core_new_memory_pool(&fh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
switch_set_flag(fh, SWITCH_TIMER_FLAG_FREE_POOL);
|
||||
return status;
|
||||
}
|
||||
switch_set_flag(fh, SWITCH_TIMER_FLAG_FREE_POOL);
|
||||
}
|
||||
|
||||
return fh->file_interface->file_open(fh, file_path);
|
||||
@@ -361,14 +361,14 @@ SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void *data, size_t *len)
|
||||
{
|
||||
assert(fh != NULL);
|
||||
|
||||
|
||||
return fh->file_interface->file_read(fh, data, len);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len)
|
||||
{
|
||||
assert(fh != NULL);
|
||||
|
||||
|
||||
return fh->file_interface->file_write(fh, data, len);
|
||||
}
|
||||
|
||||
@@ -458,14 +458,14 @@ static void *switch_core_service_thread(switch_thread *thread, void *obj)
|
||||
|
||||
while(data->running > 0) {
|
||||
switch(switch_core_session_read_frame(session, &read_frame, -1)) {
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
break;
|
||||
case SWITCH_STATUS_TIMEOUT:
|
||||
break;
|
||||
default:
|
||||
data->running = -1;
|
||||
continue;
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
break;
|
||||
case SWITCH_STATUS_TIMEOUT:
|
||||
break;
|
||||
default:
|
||||
data->running = -1;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
switch_yield(100);
|
||||
@@ -504,7 +504,7 @@ SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_se
|
||||
}
|
||||
|
||||
/* **ONLY** alloc things with this function that **WILL NOT** outlive
|
||||
the session itself or expect an earth shattering KABOOM!*/
|
||||
the session itself or expect an earth shattering KABOOM!*/
|
||||
SWITCH_DECLARE(void *)switch_core_session_alloc(switch_core_session *session, size_t memory)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
@@ -518,7 +518,7 @@ SWITCH_DECLARE(void *)switch_core_session_alloc(switch_core_session *session, si
|
||||
}
|
||||
|
||||
/* **ONLY** alloc things with these functions that **WILL NOT** need
|
||||
to be freed *EVER* ie this is for *PERMENANT* memory allocation */
|
||||
to be freed *EVER* ie this is for *PERMENANT* memory allocation */
|
||||
|
||||
SWITCH_DECLARE(void *) switch_core_permenant_alloc(size_t memory)
|
||||
{
|
||||
@@ -597,9 +597,9 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_private(switch_core_sessio
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_session *session,
|
||||
char *endpoint_name,
|
||||
switch_caller_profile *caller_profile,
|
||||
switch_core_session **new_session)
|
||||
char *endpoint_name,
|
||||
switch_caller_profile *caller_profile,
|
||||
switch_core_session **new_session)
|
||||
{
|
||||
struct switch_io_event_hook_outgoing_channel *ptr;
|
||||
switch_status status = SWITCH_STATUS_FALSE;
|
||||
@@ -710,35 +710,35 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
unsigned int flag = 0;
|
||||
session->raw_read_frame.datalen = session->raw_read_frame.buflen;
|
||||
status = switch_core_codec_decode(read_frame->codec,
|
||||
session->read_codec,
|
||||
read_frame->data,
|
||||
read_frame->datalen,
|
||||
read_frame->rate,
|
||||
session->raw_read_frame.data,
|
||||
&session->raw_read_frame.datalen,
|
||||
&session->raw_read_frame.rate,
|
||||
&flag);
|
||||
session->read_codec,
|
||||
read_frame->data,
|
||||
read_frame->datalen,
|
||||
read_frame->rate,
|
||||
session->raw_read_frame.data,
|
||||
&session->raw_read_frame.datalen,
|
||||
&session->raw_read_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
if (!session->read_resampler) {
|
||||
switch_resample_create(&session->read_resampler,
|
||||
read_frame->codec->implementation->samples_per_second,
|
||||
read_frame->codec->implementation->bytes_per_frame * 10,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->read_codec->implementation->bytes_per_frame * 10,
|
||||
session->pool);
|
||||
}
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
read_frame = &session->raw_read_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
if (!session->read_resampler) {
|
||||
switch_resample_create(&session->read_resampler,
|
||||
read_frame->codec->implementation->samples_per_second,
|
||||
read_frame->codec->implementation->bytes_per_frame * 10,
|
||||
session->read_codec->implementation->samples_per_second,
|
||||
session->read_codec->implementation->bytes_per_frame * 10,
|
||||
session->pool);
|
||||
}
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
read_frame = &session->raw_read_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (session->read_resampler) {
|
||||
@@ -778,36 +778,36 @@ SWITCH_DECLARE(switch_status) switch_core_session_read_frame(switch_core_session
|
||||
enc_frame = *frame;
|
||||
} 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->raw_read_frame.data,
|
||||
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;
|
||||
}
|
||||
session->enc_read_frame.datalen = session->enc_read_frame.buflen;
|
||||
status = switch_core_codec_encode(session->read_codec,
|
||||
(*frame)->codec,
|
||||
session->raw_read_frame.data,
|
||||
session->raw_read_frame.datalen,
|
||||
session->raw_read_frame.rate,
|
||||
session->enc_read_frame.data,
|
||||
&session->enc_read_frame.datalen,
|
||||
&session->enc_read_frame.rate,
|
||||
&flag);
|
||||
(*frame)->codec,
|
||||
session->raw_read_frame.data,
|
||||
session->raw_read_frame.datalen,
|
||||
session->raw_read_frame.rate,
|
||||
session->enc_read_frame.data,
|
||||
&session->enc_read_frame.datalen,
|
||||
&session->enc_read_frame.rate,
|
||||
&flag);
|
||||
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
*frame = &session->enc_read_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
*frame = &session->raw_read_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
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;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
*frame = &session->enc_read_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
*frame = &session->raw_read_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -857,38 +857,38 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
if (frame->codec) {
|
||||
session->raw_write_frame.datalen = session->raw_write_frame.buflen;
|
||||
status = switch_core_codec_decode(frame->codec,
|
||||
session->write_codec,
|
||||
frame->data,
|
||||
frame->datalen,
|
||||
frame->rate,
|
||||
session->raw_write_frame.data,
|
||||
&session->raw_write_frame.datalen,
|
||||
&session->raw_write_frame.rate,
|
||||
&flag);
|
||||
session->write_codec,
|
||||
frame->data,
|
||||
frame->datalen,
|
||||
frame->rate,
|
||||
session->raw_write_frame.data,
|
||||
&session->raw_write_frame.datalen,
|
||||
&session->raw_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
write_frame = &session->raw_write_frame;
|
||||
if (!session->write_resampler) {
|
||||
status = switch_resample_create(&session->write_resampler,
|
||||
frame->codec->implementation->samples_per_second,
|
||||
frame->codec->implementation->bytes_per_frame * 10,
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->write_codec->implementation->bytes_per_frame * 10,
|
||||
session->pool);
|
||||
}
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->raw_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
case SWITCH_STATUS_RESAMPLE:
|
||||
write_frame = &session->raw_write_frame;
|
||||
if (!session->write_resampler) {
|
||||
status = switch_resample_create(&session->write_resampler,
|
||||
frame->codec->implementation->samples_per_second,
|
||||
frame->codec->implementation->bytes_per_frame * 10,
|
||||
session->write_codec->implementation->samples_per_second,
|
||||
session->write_codec->implementation->bytes_per_frame * 10,
|
||||
session->pool);
|
||||
}
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->raw_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (session->write_resampler) {
|
||||
@@ -913,10 +913,10 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
if (!session->raw_write_buffer) {
|
||||
int bytes = session->write_codec->implementation->bytes_per_frame * 10;
|
||||
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);
|
||||
"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) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Write Buffer Failed!\n");
|
||||
return status;
|
||||
@@ -932,28 +932,28 @@ SWITCH_DECLARE(switch_status) switch_core_session_write_frame(switch_core_sessio
|
||||
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
|
||||
|
||||
status = switch_core_codec_encode(session->write_codec,
|
||||
frame->codec,
|
||||
enc_frame->data,
|
||||
enc_frame->datalen,
|
||||
enc_frame->rate,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
frame->codec,
|
||||
enc_frame->data,
|
||||
enc_frame->datalen,
|
||||
enc_frame->rate,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->enc_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = enc_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->enc_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = enc_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
|
||||
status = perform_write(session, write_frame, timeout, io_flag);
|
||||
@@ -968,40 +968,40 @@ 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;
|
||||
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
|
||||
status = switch_core_codec_encode(session->write_codec,
|
||||
frame->codec,
|
||||
enc_frame->data,
|
||||
enc_frame->datalen,
|
||||
enc_frame->rate,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
enc_frame = &session->raw_write_frame;
|
||||
session->raw_write_frame.rate = session->write_codec->implementation->samples_per_second;
|
||||
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
|
||||
status = switch_core_codec_encode(session->write_codec,
|
||||
frame->codec,
|
||||
enc_frame->data,
|
||||
enc_frame->datalen,
|
||||
enc_frame->rate,
|
||||
session->enc_write_frame.data,
|
||||
&session->enc_write_frame.datalen,
|
||||
&session->enc_write_frame.rate,
|
||||
&flag);
|
||||
|
||||
|
||||
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->enc_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = enc_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
status = perform_write(session, write_frame, timeout, io_flag);
|
||||
switch (status) {
|
||||
case SWITCH_STATUS_SUCCESS:
|
||||
write_frame = &session->enc_write_frame;
|
||||
break;
|
||||
case SWITCH_STATUS_NOOP:
|
||||
write_frame = enc_frame;
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Codec %s encoder error!\n", session->read_codec->codec_interface->interface_name);
|
||||
write_frame = NULL;
|
||||
return status;
|
||||
break;
|
||||
}
|
||||
status = perform_write(session, write_frame, timeout, io_flag);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
@@ -1298,7 +1298,7 @@ static void switch_core_standard_on_init(switch_core_session *session)
|
||||
|
||||
static void switch_core_standard_on_hangup(switch_core_session *session)
|
||||
{
|
||||
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Standard HANGUP %s\n", switch_channel_get_name(session->channel));
|
||||
|
||||
}
|
||||
@@ -1324,7 +1324,7 @@ static void switch_core_standard_on_ring(switch_core_session *session)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void switch_core_standard_on_execute(switch_core_session *session)
|
||||
{
|
||||
@@ -1341,7 +1341,7 @@ 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,
|
||||
extension->current_application->application_data);
|
||||
extension->current_application->application_data);
|
||||
if (!(application_interface = 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);
|
||||
@@ -1394,17 +1394,17 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
||||
const switch_event_handler_table *application_event_handlers = NULL;
|
||||
|
||||
/*
|
||||
Life of the channel. you have channel and pool in your session
|
||||
everywhere you go you use the session to malloc with
|
||||
switch_core_session_alloc(session, <size>)
|
||||
Life of the channel. you have channel and pool in your session
|
||||
everywhere you go you use the session to malloc with
|
||||
switch_core_session_alloc(session, <size>)
|
||||
|
||||
The enpoint module gets the first crack at implementing the state
|
||||
if it wants to, it can cancel the default behaviour by returning SWITCH_STATUS_FALSE
|
||||
The enpoint module gets the first crack at implementing the state
|
||||
if it wants to, it can cancel the default behaviour by returning SWITCH_STATUS_FALSE
|
||||
|
||||
Next comes the channel's event handler table that can be set by an application
|
||||
which also can veto the next behaviour in line by returning SWITCH_STATUS_FALSE
|
||||
Next comes the channel's event handler table that can be set by an application
|
||||
which also can veto the next behaviour in line by returning SWITCH_STATUS_FALSE
|
||||
|
||||
Finally the default state behaviour is called.
|
||||
Finally the default state behaviour is called.
|
||||
|
||||
|
||||
*/
|
||||
@@ -1431,97 +1431,97 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
||||
}
|
||||
|
||||
switch ( state ) {
|
||||
case CS_NEW: /* Just created, Waiting for first instructions */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State NEW\n");
|
||||
break;
|
||||
case CS_DONE:
|
||||
continue;
|
||||
break;
|
||||
case CS_HANGUP: /* Deactivate and end the thread */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State HANGUP\n");
|
||||
if (!driver_event_handlers->on_hangup ||
|
||||
(driver_event_handlers->on_hangup &&
|
||||
driver_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_hangup ||
|
||||
(application_event_handlers->on_hangup &&
|
||||
application_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_hangup(session);
|
||||
}
|
||||
}
|
||||
switch_channel_set_state(session->channel, CS_DONE);
|
||||
break;
|
||||
case CS_INIT: /* Basic setup tasks */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
|
||||
if (!driver_event_handlers->on_init ||
|
||||
(driver_event_handlers->on_init &&
|
||||
driver_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_init ||
|
||||
(application_event_handlers->on_init &&
|
||||
application_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_init(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_RING: /* Look for a dialplan and find something to do */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State RING\n");
|
||||
if (!driver_event_handlers->on_ring ||
|
||||
(driver_event_handlers->on_ring &&
|
||||
driver_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_ring ||
|
||||
(application_event_handlers->on_ring &&
|
||||
application_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_ring(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_EXECUTE: /* Execute an Operation*/
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State EXECUTE\n");
|
||||
if (!driver_event_handlers->on_execute ||
|
||||
(driver_event_handlers->on_execute &&
|
||||
driver_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_execute ||
|
||||
(application_event_handlers->on_execute &&
|
||||
application_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_execute(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_LOOPBACK: /* loop all data back to source */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State LOOPBACK\n");
|
||||
if (!driver_event_handlers->on_loopback ||
|
||||
(driver_event_handlers->on_loopback &&
|
||||
driver_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_loopback ||
|
||||
(application_event_handlers->on_loopback &&
|
||||
application_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_loopback(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_TRANSMIT: /* send/recieve data to/from another channel */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State TRANSMIT\n");
|
||||
if (!driver_event_handlers->on_transmit ||
|
||||
(driver_event_handlers->on_transmit &&
|
||||
driver_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_transmit ||
|
||||
(application_event_handlers->on_transmit &&
|
||||
application_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_transmit(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_NEW: /* Just created, Waiting for first instructions */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State NEW\n");
|
||||
break;
|
||||
case CS_DONE:
|
||||
continue;
|
||||
break;
|
||||
case CS_HANGUP: /* Deactivate and end the thread */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State HANGUP\n");
|
||||
if (!driver_event_handlers->on_hangup ||
|
||||
(driver_event_handlers->on_hangup &&
|
||||
driver_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_hangup ||
|
||||
(application_event_handlers->on_hangup &&
|
||||
application_event_handlers->on_hangup(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_hangup(session);
|
||||
}
|
||||
}
|
||||
switch_channel_set_state(session->channel, CS_DONE);
|
||||
break;
|
||||
case CS_INIT: /* Basic setup tasks */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State INIT\n");
|
||||
if (!driver_event_handlers->on_init ||
|
||||
(driver_event_handlers->on_init &&
|
||||
driver_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_init ||
|
||||
(application_event_handlers->on_init &&
|
||||
application_event_handlers->on_init(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_init(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_RING: /* Look for a dialplan and find something to do */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State RING\n");
|
||||
if (!driver_event_handlers->on_ring ||
|
||||
(driver_event_handlers->on_ring &&
|
||||
driver_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_ring ||
|
||||
(application_event_handlers->on_ring &&
|
||||
application_event_handlers->on_ring(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_ring(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_EXECUTE: /* Execute an Operation*/
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State EXECUTE\n");
|
||||
if (!driver_event_handlers->on_execute ||
|
||||
(driver_event_handlers->on_execute &&
|
||||
driver_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_execute ||
|
||||
(application_event_handlers->on_execute &&
|
||||
application_event_handlers->on_execute(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_execute(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_LOOPBACK: /* loop all data back to source */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State LOOPBACK\n");
|
||||
if (!driver_event_handlers->on_loopback ||
|
||||
(driver_event_handlers->on_loopback &&
|
||||
driver_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_loopback ||
|
||||
(application_event_handlers->on_loopback &&
|
||||
application_event_handlers->on_loopback(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_loopback(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CS_TRANSMIT: /* send/recieve data to/from another channel */
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "State TRANSMIT\n");
|
||||
if (!driver_event_handlers->on_transmit ||
|
||||
(driver_event_handlers->on_transmit &&
|
||||
driver_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
if (!application_event_handlers || !application_event_handlers->on_transmit ||
|
||||
(application_event_handlers->on_transmit &&
|
||||
application_event_handlers->on_transmit(session) == SWITCH_STATUS_SUCCESS &&
|
||||
midstate == switch_channel_get_state(session->channel))) {
|
||||
switch_core_standard_on_transmit(session);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
laststate = midstate;
|
||||
@@ -1581,16 +1581,16 @@ SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash *hash, char *key)
|
||||
}
|
||||
|
||||
/* This function abstracts the thread creation for modules by allowing you to pass a function ptr and
|
||||
a void object and trust that that the function will be run in a thread with arg This lets
|
||||
you request and activate a thread without giving up any knowledge about what is in the thread
|
||||
neither the core nor the calling module know anything about each other.
|
||||
a void object and trust that that the function will be run in a thread with arg This lets
|
||||
you request and activate a thread without giving up any knowledge about what is in the thread
|
||||
neither the core nor the calling module know anything about each other.
|
||||
|
||||
This thread is expected to never exit until the application exits so the func is responsible
|
||||
to make sure that is the case.
|
||||
This thread is expected to never exit until the application exits so the func is responsible
|
||||
to make sure that is the case.
|
||||
|
||||
The typical use for this is so switch_loadable_module.c can start up a thread for each module
|
||||
passing the table of module methods as a session obj into the core without actually allowing
|
||||
the core to have any clue and keeping switch_loadable_module.c from needing any thread code.
|
||||
The typical use for this is so switch_loadable_module.c can start up a thread for each module
|
||||
passing the table of module methods as a session obj into the core without actually allowing
|
||||
the core to have any clue and keeping switch_loadable_module.c from needing any thread code.
|
||||
|
||||
*/
|
||||
|
||||
@@ -1605,10 +1605,10 @@ SWITCH_DECLARE(void) switch_core_launch_thread(switch_thread_start_t func, void
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(ts = switch_core_alloc(pool, sizeof(*ts)))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory\n");
|
||||
} else {
|
||||
@@ -1616,11 +1616,11 @@ 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,
|
||||
ts->pool
|
||||
);
|
||||
thd_attr,
|
||||
func,
|
||||
ts,
|
||||
ts->pool
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1655,12 +1655,12 @@ SWITCH_DECLARE(void) switch_core_session_thread_launch(switch_core_session *sess
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
if (switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
switch_core_session_thread,
|
||||
session,
|
||||
session->pool
|
||||
) != APR_SUCCESS) {
|
||||
switch_core_session_destroy(&session);
|
||||
thd_attr,
|
||||
switch_core_session_thread,
|
||||
session,
|
||||
session->pool
|
||||
) != APR_SUCCESS) {
|
||||
switch_core_session_destroy(&session);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1673,11 +1673,11 @@ SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session *sess
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
|
||||
switch_thread_create(&thread,
|
||||
thd_attr,
|
||||
func,
|
||||
obj,
|
||||
session->pool
|
||||
);
|
||||
thd_attr,
|
||||
func,
|
||||
obj,
|
||||
session->pool
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1723,7 +1723,7 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
|
||||
switch_channel_init(session->channel, session, CS_NEW, CF_SEND_AUDIO | CF_RECV_AUDIO);
|
||||
|
||||
/* The session *IS* the pool you may not alter it because you have no idea how
|
||||
its all private it will be passed to the thread run function */
|
||||
its all private it will be passed to the thread run function */
|
||||
|
||||
switch_uuid_get(&uuid);
|
||||
switch_uuid_format(session->uuid_str, &uuid);
|
||||
@@ -1735,7 +1735,7 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
|
||||
session->raw_write_frame.buflen = sizeof(session->raw_write_buf);
|
||||
session->raw_read_frame.data = session->raw_read_buf;
|
||||
session->raw_read_frame.buflen = sizeof(session->raw_read_buf);
|
||||
|
||||
|
||||
|
||||
session->enc_write_frame.data = session->enc_write_buf;
|
||||
session->enc_write_frame.buflen = sizeof(session->enc_write_buf);
|
||||
@@ -1744,7 +1744,7 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
|
||||
|
||||
switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED ,session->pool);
|
||||
switch_thread_cond_create(&session->cond, session->pool);
|
||||
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
@@ -1766,13 +1766,13 @@ static void core_event_handler (switch_event *event)
|
||||
char buf[1024];
|
||||
|
||||
switch(event->event_id) {
|
||||
case SWITCH_EVENT_LOG:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
switch_event_serialize(event, buf, sizeof(buf), NULL);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "\nCORE EVENT\n--------------------------------\n%s\n", buf);
|
||||
break;
|
||||
case SWITCH_EVENT_LOG:
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
switch_event_serialize(event, buf, sizeof(buf), NULL);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "\nCORE EVENT\n--------------------------------\n%s\n", buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user