cleanup and formating

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@261 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2006-01-03 01:17:59 +00:00
parent 900c08571b
commit bedcabb8ec
20 changed files with 1075 additions and 1167 deletions

View File

@ -75,8 +75,8 @@ extern "C" {
if (!(jrtp4c->session = new JRTP4C)) {
*err = "Memory Error!\n";
delete jrtp4c->transparams;
delete jrtp4c;
return NULL;
delete jrtp4c;
return NULL;
}
if ((status = jrtp4c->session->Create(sessparams, jrtp4c->transparams)) < 0) {

View File

@ -76,14 +76,14 @@ static switch_status switch_gsm_destroy(switch_codec *codec)
static switch_status switch_gsm_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)
{
struct gsm_context *context = codec->private;
int cbret = 0;
@ -116,14 +116,14 @@ static switch_status switch_gsm_encode(switch_codec *codec,
static switch_status switch_gsm_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)
{
struct gsm_context *context = codec->private;
@ -140,7 +140,7 @@ static switch_status switch_gsm_decode(switch_codec *codec,
unsigned int new_len = 0;
for(x = 0; x < loops && new_len < *decoded_data_len; x++) {
gsm_decode(context->decoder, edp, ddp);
ddp += 160;
ddp += 160;
edp += 33;
new_len += 320;
}

View File

@ -61,12 +61,12 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
switch_channel_state b_state = switch_channel_get_state(chan_b);
switch (b_state) {
case CS_HANGUP:
data->running = -1;
continue;
break;
default:
break;
case CS_HANGUP:
data->running = -1;
continue;
break;
default:
break;
}
if (switch_channel_has_dtmf(chan_a)) {
@ -137,7 +137,7 @@ static const switch_event_handler_table audio_bridge_peer_event_handlers = {
/*.on_init*/ NULL,
/*.on_ring*/ audio_bridge_on_ring,
/*.on_execute*/ NULL,
/*.on_hangup*/ audio_bridge_on_hangup,
/*.on_hangup*/ audio_bridge_on_hangup,
/*.on_loopback*/ NULL,
/*.on_transmit*/ NULL
};
@ -146,7 +146,7 @@ static const switch_event_handler_table audio_bridge_caller_event_handlers = {
/*.on_init*/ NULL,
/*.on_ring*/ NULL,
/*.on_execute*/ NULL,
/*.on_hangup*/ audio_bridge_on_hangup,
/*.on_hangup*/ audio_bridge_on_hangup,
/*.on_loopback*/ NULL,
/*.on_transmit*/ NULL
};
@ -171,13 +171,13 @@ static void audio_bridge_function(switch_core_session *session, char *data)
caller_caller_profile = switch_channel_get_caller_profile(caller_channel);
caller_profile = switch_caller_profile_new(session,
caller_caller_profile->dialplan,
caller_caller_profile->caller_id_name,
caller_caller_profile->caller_id_number,
caller_caller_profile->network_addr,
NULL,
NULL,
chan_data);
caller_caller_profile->dialplan,
caller_caller_profile->caller_id_name,
caller_caller_profile->caller_id_number,
caller_caller_profile->network_addr,
NULL,
NULL,
chan_data);
@ -217,10 +217,10 @@ static void audio_bridge_function(switch_core_session *session, char *data)
time(&start);
while(switch_channel_get_state(caller_channel) == CS_EXECUTE &&
switch_channel_get_state(peer_channel) == CS_TRANSMIT &&
!switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
((time(NULL) - start) < timelimit)) {
switch_yield(20000);
switch_channel_get_state(peer_channel) == CS_TRANSMIT &&
!switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
((time(NULL) - start) < timelimit)) {
switch_yield(20000);
}
if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {

View File

@ -71,14 +71,14 @@ static switch_status switch_g729_destroy(switch_codec *codec)
static switch_status switch_g729_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)
{
struct g729_context *context = codec->private;
int cbret = 0;
@ -111,14 +111,14 @@ static switch_status switch_g729_encode(switch_codec *codec,
static switch_status switch_g729_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)
{
struct g729_context *context = codec->private;

View File

@ -122,7 +122,3 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}

View File

@ -30,7 +30,6 @@
*
*/
#define HAVE_APR
#include <switch.h>
#include <jrtp4c.h>
@ -191,25 +190,25 @@ static int sdp_add_codec(struct osip_rfc3264 *cnf, int codec_type, int payload,
}
switch (codec_type) {
case SWITCH_CODEC_TYPE_AUDIO:
med->m_media = osip_strdup("audio");
osip_rfc3264_add_audio_media(cnf, med, -1);
break;
case SWITCH_CODEC_TYPE_VIDEO:
med->m_media = osip_strdup("video");
osip_rfc3264_add_video_media(cnf, med, -1);
break;
default:
break;
case SWITCH_CODEC_TYPE_AUDIO:
med->m_media = osip_strdup("audio");
osip_rfc3264_add_audio_media(cnf, med, -1);
break;
case SWITCH_CODEC_TYPE_VIDEO:
med->m_media = osip_strdup("video");
osip_rfc3264_add_video_media(cnf, med, -1);
break;
default:
break;
}
return 0;
return 0;
}
/*
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
static switch_status exosip_on_init(switch_core_session *session)
{
@ -454,25 +453,25 @@ static void activate_rtp(struct private_object *tech_pvt)
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activating RTP %s:%d->%s:%d codec: %d ms: %d\n",
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.codec_interface->ianacode,
ms
);
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.codec_interface->ianacode,
ms
);
tech_pvt->rtp_session = jrtp4c_new(
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.codec_interface->ianacode,
tech_pvt->read_codec.implementation->samples_per_second,
&err);
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
tech_pvt->remote_sdp_audio_port,
tech_pvt->read_codec.codec_interface->ianacode,
tech_pvt->read_codec.implementation->samples_per_second,
&err);
if (tech_pvt->rtp_session) {
tech_pvt->ssrc = jrtp4c_get_ssrc(tech_pvt->rtp_session);
@ -555,8 +554,8 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
tech_pvt->read_frame.datalen = jrtp4c_read(tech_pvt->rtp_session,
tech_pvt->read_frame.data,
sizeof(tech_pvt->read_buf));
tech_pvt->read_frame.data,
sizeof(tech_pvt->read_buf));
if (tech_pvt->read_frame.datalen > 0) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
@ -794,14 +793,14 @@ static switch_status exosip_create_call(eXosip_event_t *event)
}
if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan,
event->request->from->displayname,
event->request->from->url->username,
event->request->from->url->host,
NULL,
NULL,
event->request->req_uri->username))) {
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
globals.dialplan,
event->request->from->displayname,
event->request->from->url->username,
event->request->from->url->host,
NULL,
NULL,
event->request->req_uri->username))) {
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
}
switch_set_flag(tech_pvt, TFLAG_INBOUND);
@ -887,28 +886,28 @@ static switch_status exosip_create_call(eXosip_event_t *event)
int rate = atoi(drate);
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return SWITCH_STATUS_FALSE;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return SWITCH_STATUS_FALSE;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return SWITCH_STATUS_FALSE;
} else {
int ms;
tech_pvt->read_frame.rate = rate;
@ -1052,28 +1051,28 @@ static void handle_answer(eXosip_event_t *event)
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
rate,
globals.codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_channel_hangup(channel);
return;
} else {
int ms;
tech_pvt->read_frame.rate = rate;
@ -1119,78 +1118,78 @@ static void log_event(eXosip_event_t *je)
} else if (je->type == EXOSIP_CALL_RELEASED) {
snprintf (buf, 99, "<- (%i %i) Call released", je->cid, je->did);
} else if (je->type == EXOSIP_MESSAGE_NEW
&& je->request!=NULL && MSG_IS_MESSAGE(je->request)) {
char *tmp = NULL;
&& je->request!=NULL && MSG_IS_MESSAGE(je->request)) {
char *tmp = NULL;
if (je->request != NULL) {
osip_body_t *body;
osip_from_to_str (je->request->from, &tmp);
if (je->request != NULL) {
osip_body_t *body;
osip_from_to_str (je->request->from, &tmp);
osip_message_get_body (je->request, 0, &body);
if (body != NULL && body->body != NULL) {
snprintf (buf, 99, "<- (%i) from: %s TEXT: %s",
je->tid, tmp, body->body);
osip_message_get_body (je->request, 0, &body);
if (body != NULL && body->body != NULL) {
snprintf (buf, 99, "<- (%i) from: %s TEXT: %s",
je->tid, tmp, body->body);
}
osip_free (tmp);
} else {
snprintf (buf, 99, "<- (%i) New event for unknown request?", je->tid);
}
osip_free (tmp);
} else {
snprintf (buf, 99, "<- (%i) New event for unknown request?", je->tid);
}
} else if (je->type == EXOSIP_MESSAGE_NEW) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (%i) %s from: %s",
je->tid, je->request->sip_method, tmp);
je->tid, je->request->sip_method, tmp);
osip_free (tmp);
} else if (je->type == EXOSIP_MESSAGE_PROCEEDING
|| je->type == EXOSIP_MESSAGE_ANSWERED
|| je->type == EXOSIP_MESSAGE_REDIRECTED
|| je->type == EXOSIP_MESSAGE_REQUESTFAILURE
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE
|| je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
if (je->response != NULL && je->request != NULL) {
char *tmp = NULL;
|| je->type == EXOSIP_MESSAGE_ANSWERED
|| je->type == EXOSIP_MESSAGE_REDIRECTED
|| je->type == EXOSIP_MESSAGE_REQUESTFAILURE
|| je->type == EXOSIP_MESSAGE_SERVERFAILURE
|| je->type == EXOSIP_MESSAGE_GLOBALFAILURE) {
if (je->response != NULL && je->request != NULL) {
char *tmp = NULL;
osip_to_to_str (je->request->to, &tmp);
snprintf (buf, 99, "<- (%i) [%i %s for %s] to: %s",
je->tid, je->response->status_code,
je->response->reason_phrase, je->request->sip_method, tmp);
osip_free (tmp);
} else if (je->request != NULL) {
snprintf (buf, 99, "<- (%i) Error for %s request",
je->tid, je->request->sip_method);
} else {
snprintf (buf, 99, "<- (%i) Error for unknown request", je->tid);
}
osip_to_to_str (je->request->to, &tmp);
snprintf (buf, 99, "<- (%i) [%i %s for %s] to: %s",
je->tid, je->response->status_code,
je->response->reason_phrase, je->request->sip_method, tmp);
osip_free (tmp);
} else if (je->request != NULL) {
snprintf (buf, 99, "<- (%i) Error for %s request",
je->tid, je->request->sip_method);
} else {
snprintf (buf, 99, "<- (%i) Error for unknown request", je->tid);
}
} else if (je->response == NULL && je->request != NULL && je->cid > 0) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (%i %i) %s from: %s",
je->cid, je->did, je->request->cseq->method, tmp);
je->cid, je->did, je->request->cseq->method, tmp);
osip_free (tmp);
} else if (je->response != NULL && je->cid > 0) {
char *tmp = NULL;
osip_to_to_str (je->request->to, &tmp);
snprintf (buf, 99, "<- (%i %i) [%i %s] for %s to: %s",
je->cid, je->did, je->response->status_code,
je->response->reason_phrase, je->request->sip_method, tmp);
je->cid, je->did, je->response->status_code,
je->response->reason_phrase, je->request->sip_method, tmp);
osip_free (tmp);
} else if (je->response == NULL && je->request != NULL && je->rid > 0) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (%i) %s from: %s",
je->rid, je->request->cseq->method, tmp);
je->rid, je->request->cseq->method, tmp);
osip_free (tmp);
} else if (je->response != NULL && je->rid > 0) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
je->rid, je->response->status_code,
je->response->reason_phrase, tmp);
je->rid, je->response->status_code,
je->response->reason_phrase, tmp);
osip_free (tmp);
} else if (je->response == NULL && je->request != NULL && je->sid > 0) {
char *tmp = NULL;
@ -1198,42 +1197,42 @@ static void log_event(eXosip_event_t *je)
osip_header_t *sub_state;
osip_message_header_get_byname (je->request, "subscription-state",
0, &sub_state);
0, &sub_state);
if (sub_state != NULL && sub_state->hvalue != NULL)
stat = sub_state->hvalue;
osip_uri_to_str (je->request->from->url, &tmp);
snprintf (buf, 99, "<- (%i) [%s] %s from: %s",
je->sid, stat, je->request->cseq->method, tmp);
je->sid, stat, je->request->cseq->method, tmp);
osip_free (tmp);
} else if (je->response != NULL && je->sid > 0) {
char *tmp = NULL;
osip_uri_to_str (je->request->to->url, &tmp);
snprintf (buf, 99, "<- (%i) [%i %s] from: %s",
je->sid, je->response->status_code,
je->response->reason_phrase, tmp);
je->sid, je->response->status_code,
je->response->reason_phrase, tmp);
osip_free (tmp);
} else if (je->response == NULL && je->request != NULL) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) %s from: %s",
je->cid, je->did, je->sid, je->nid,
je->request->sip_method, tmp);
je->cid, je->did, je->sid, je->nid,
je->request->sip_method, tmp);
osip_free (tmp);
} else if (je->response != NULL) {
char *tmp = NULL;
osip_from_to_str (je->request->from, &tmp);
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i) [%i %s] for %s from: %s",
je->cid, je->did, je->sid, je->nid,
je->response->status_code, je->response->reason_phrase,
je->request->sip_method, tmp);
je->cid, je->did, je->sid, je->nid,
je->response->status_code, je->response->reason_phrase,
je->request->sip_method, tmp);
osip_free (tmp);
} else {
snprintf (buf, 99, "<- (c=%i|d=%i|s=%i|n=%i|t=%i) %s",
je->cid, je->did, je->sid, je->nid, je->tid, je->textinfo);
je->cid, je->did, je->sid, je->nid, je->tid, je->textinfo);
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "\n%s\n", buf);
/* Print it out */
@ -1259,64 +1258,64 @@ static void *monitor_thread_run(void)
log_event(event);
switch(event->type) {
case EXOSIP_CALL_INVITE:
exosip_create_call(event);
break;
case EXOSIP_CALL_REINVITE:
/* See what the reinvite is about - on hold or whatever */
//handle_reinvite(event);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Got a reinvite.\n");
break;
case EXOSIP_CALL_MESSAGE_NEW:
if (event->request != NULL && MSG_IS_REFER(event->request)) {
//handle_call_transfer(event);
}
break;
case EXOSIP_CALL_ACK:
/* If audio is not flowing and this has SDP - fire it up! */
break;
case EXOSIP_CALL_ANSWERED:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "The call was answered.\n");
handle_answer(event);
break;
case EXOSIP_CALL_PROCEEDING:
/* This is like a 100 Trying... yeah */
break;
case EXOSIP_CALL_RINGING:
//handle_ringing(event);
break;
case EXOSIP_CALL_REDIRECTED:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call was redirect\n");
break;
case EXOSIP_CALL_CLOSED:
destroy_call_by_event(event);
break;
case EXOSIP_CALL_RELEASED:
destroy_call_by_event(event);
break;
case EXOSIP_CALL_NOANSWER:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "The call was not answered.\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_REQUESTFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Request failure\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_SERVERFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Server failure\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_GLOBALFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Global failure\n");
destroy_call_by_event(event);
break;
/* Registration related stuff */
case EXOSIP_REGISTRATION_NEW:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Received registration attempt\n");
break;
default:
/* Unknown event... casually absorb it for now */
break;
case EXOSIP_CALL_INVITE:
exosip_create_call(event);
break;
case EXOSIP_CALL_REINVITE:
/* See what the reinvite is about - on hold or whatever */
//handle_reinvite(event);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Got a reinvite.\n");
break;
case EXOSIP_CALL_MESSAGE_NEW:
if (event->request != NULL && MSG_IS_REFER(event->request)) {
//handle_call_transfer(event);
}
break;
case EXOSIP_CALL_ACK:
/* If audio is not flowing and this has SDP - fire it up! */
break;
case EXOSIP_CALL_ANSWERED:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "The call was answered.\n");
handle_answer(event);
break;
case EXOSIP_CALL_PROCEEDING:
/* This is like a 100 Trying... yeah */
break;
case EXOSIP_CALL_RINGING:
//handle_ringing(event);
break;
case EXOSIP_CALL_REDIRECTED:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call was redirect\n");
break;
case EXOSIP_CALL_CLOSED:
destroy_call_by_event(event);
break;
case EXOSIP_CALL_RELEASED:
destroy_call_by_event(event);
break;
case EXOSIP_CALL_NOANSWER:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "The call was not answered.\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_REQUESTFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Request failure\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_SERVERFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Server failure\n");
destroy_call_by_event(event);
break;
case EXOSIP_CALL_GLOBALFAILURE:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Global failure\n");
destroy_call_by_event(event);
break;
/* Registration related stuff */
case EXOSIP_REGISTRATION_NEW:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Received registration attempt\n");
break;
default:
/* Unknown event... casually absorb it for now */
break;
}
//switch_console_printf(SWITCH_CHANNEL_CONSOLE, "There was an event (%d) [%s]\n", event->type, event->textinfo);

View File

@ -52,14 +52,14 @@ static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag fl
static switch_status switch_g711u_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)
{
short *dbuf;
unsigned char *ebuf;
@ -78,14 +78,14 @@ static switch_status switch_g711u_encode(switch_codec *codec,
}
static switch_status switch_g711u_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)
{
short *dbuf;
unsigned char *ebuf;
@ -130,14 +130,14 @@ static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag fl
static switch_status switch_g711a_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)
{
short *dbuf;
unsigned char *ebuf;
@ -156,14 +156,14 @@ static switch_status switch_g711a_encode(switch_codec *codec,
}
static switch_status switch_g711a_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)
{
short *dbuf;
unsigned char *ebuf;

View File

@ -75,7 +75,7 @@ static struct {
struct private_object {
unsigned int flags;
switch_codec read_codec;
switch_codec write_codec;
switch_codec write_codec;
struct switch_frame read_frame;
unsigned char databuf[1024];
switch_core_session *session;
@ -174,12 +174,12 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
if (globals.codec_string) {
if (!(num_codecs = loadable_module_get_codecs_sorted(switch_core_session_get_pool(tech_pvt->session),
codecs,
SWITCH_MAX_CODECS,
globals.codec_order,
globals.codec_order_last)) > 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
return SWITCH_STATUS_GENERR;
codecs,
SWITCH_MAX_CODECS,
globals.codec_order,
globals.codec_order_last)) > 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
return SWITCH_STATUS_GENERR;
}
} else if (!(num_codecs = loadable_module_get_codecs(switch_core_session_get_pool(tech_pvt->session), codecs, SWITCH_MAX_CODECS)) > 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "NO codecs?\n");
@ -272,27 +272,27 @@ static switch_status iax_set_codec(struct private_object *tech_pvt, struct iax_s
switch_set_flag(tech_pvt, TFLAG_LINEAR);
}
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
0,
0,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
return SWITCH_STATUS_GENERR;
dname,
0,
0,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
return SWITCH_STATUS_GENERR;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
0,
0,
1,
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_core_codec_destroy(&tech_pvt->read_codec);
return SWITCH_STATUS_GENERR;
dname,
0,
0,
1,
SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE,
NULL,
switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
switch_core_codec_destroy(&tech_pvt->read_codec);
return SWITCH_STATUS_GENERR;
} else {
int ms;
int rate;
@ -344,9 +344,9 @@ static void iax_out_cb(const char *s)
/*
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
static switch_status channel_on_init(switch_core_session *session)
{
@ -475,7 +475,7 @@ static switch_status channel_on_transmit(switch_core_session *session)
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile, switch_core_session **new_session)
{
@ -523,10 +523,10 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
iax_call(tech_pvt->iax_session,
caller_profile->caller_id_number,
caller_profile->caller_id_name,
caller_profile->destination_number,
NULL, 0, req, cap);
caller_profile->caller_id_number,
caller_profile->caller_id_name,
caller_profile->destination_number,
NULL, 0, req, cap);
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
@ -572,7 +572,7 @@ static switch_status channel_send_dtmf(switch_core_session *session, char *dtmf)
}
}
return SWITCH_STATUS_SUCCESS;
return SWITCH_STATUS_SUCCESS;
}
static switch_status channel_read_frame(switch_core_session *session, switch_frame **frame, int timeout, switch_io_flag flags)
@ -776,8 +776,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
}
iax_set_error(iax_err_cb);
iax_set_output(iax_out_cb);
netfd = iax_get_fd();
iax_set_output(iax_out_cb);
netfd = iax_get_fd();
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "IAX Ready Port %d\n", globals.port);
@ -796,164 +796,164 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
if (globals.debug && iaxevent->etype != IAX_EVENT_VOICE) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Event %d [%s]!\n",
iaxevent->etype, IAXNAMES[iaxevent->etype]);
iaxevent->etype, IAXNAMES[iaxevent->etype]);
}
switch (iaxevent->etype) {
case IAX_EVENT_REGACK:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration completed successfully.\n");
if (iaxevent->ies.refresh) refresh = iaxevent->ies.refresh;
break;
case IAX_EVENT_REGREJ:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration failed.\n");
break;
case IAX_EVENT_TIMEOUT:
break;
case IAX_EVENT_ACCEPT:
if (tech_pvt) {
unsigned int cap = iax_session_get_capability(iaxevent->session);
unsigned int format = iaxevent->ies.format;
case IAX_EVENT_REGACK:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration completed successfully.\n");
if (iaxevent->ies.refresh) refresh = iaxevent->ies.refresh;
break;
case IAX_EVENT_REGREJ:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Registration failed.\n");
break;
case IAX_EVENT_TIMEOUT:
break;
case IAX_EVENT_ACCEPT:
if (tech_pvt) {
unsigned int cap = iax_session_get_capability(iaxevent->session);
unsigned int format = iaxevent->ies.format;
if (iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, IAX_SET) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF? %d %d\n",iaxevent->ies.format, iaxevent->ies.capability);
if (iax_set_codec(tech_pvt, iaxevent->session, &format, &cap, IAX_SET) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "WTF? %d %d\n",iaxevent->ies.format, iaxevent->ies.capability);
}
}
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call accepted.\n");
break;
case IAX_EVENT_RINGA:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Ringing heard.\n");
break;
case IAX_EVENT_PONG:
// informative only
break;
case IAX_EVENT_ANSWER:
// the other side answered our call
if (tech_pvt) {
switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n", switch_channel_get_name(channel));
switch_channel_answer(channel);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call accepted.\n");
break;
case IAX_EVENT_RINGA:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Ringing heard.\n");
break;
case IAX_EVENT_PONG:
// informative only
break;
case IAX_EVENT_ANSWER:
// the other side answered our call
if (tech_pvt) {
switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Answer %s\n", switch_channel_get_name(channel));
switch_channel_answer(channel);
}
}
}
break;
case IAX_EVENT_CONNECT:
// incoming call detected
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
"Incoming call connected %s, %s, %s %d/%d\n",
iaxevent->ies.called_number,
iaxevent->ies.calling_number,
iaxevent->ies.calling_name,
iaxevent->ies.format,
iaxevent->ies.capability);
break;
case IAX_EVENT_CONNECT:
// incoming call detected
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
"Incoming call connected %s, %s, %s %d/%d\n",
iaxevent->ies.called_number,
iaxevent->ies.calling_number,
iaxevent->ies.calling_name,
iaxevent->ies.format,
iaxevent->ies.capability);
if (iaxevent) {
switch_core_session *session;
if (iaxevent) {
switch_core_session *session;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
struct private_object *tech_pvt;
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
struct private_object *tech_pvt;
switch_channel *channel;
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
tech_pvt->session = session;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(&session);
break;
}
if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan,
iaxevent->ies.calling_name,
iaxevent->ies.calling_number,
iax_get_peer_ip(iaxevent->session),
iaxevent->ies.calling_ani,
NULL,
iaxevent->ies.called_number))) {
char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
}
if (iax_set_codec(tech_pvt, iaxevent->session,
&iaxevent->ies.format,
&iaxevent->ies.capability,
IAX_SET) != SWITCH_STATUS_SUCCESS) {
iax_reject(iaxevent->session, "Codec Error!");
switch_core_session_destroy(&session);
} else {
tech_pvt->iax_session = iaxevent->session;
tech_pvt->session = session;
iax_accept(tech_pvt->iax_session, tech_pvt->codec);
iax_ring_announce(tech_pvt->iax_session);
switch_channel_set_state(channel, CS_INIT);
switch_core_session_thread_launch(session);
}
}
}
break;
case IAX_EVENT_REJECT:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n");
case IAX_EVENT_BUSY:
case IAX_EVENT_HANGUP:
if (tech_pvt) {
switch_channel *channel;
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt);
tech_pvt->session = session;
switch_clear_flag(tech_pvt, TFLAG_IO);
switch_clear_flag(tech_pvt, TFLAG_VOICE);
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hangup %s\n", switch_channel_get_name(channel));
switch_set_flag(tech_pvt, TFLAG_HANGUP);
switch_channel_hangup(channel);
switch_thread_cond_signal(tech_pvt->cond);
iaxevent->session = NULL;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(&session);
break;
}
if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan,
iaxevent->ies.calling_name,
iaxevent->ies.calling_number,
iax_get_peer_ip(iaxevent->session),
iaxevent->ies.calling_ani,
NULL,
iaxevent->ies.called_number))) {
char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
}
if (iax_set_codec(tech_pvt, iaxevent->session,
&iaxevent->ies.format,
&iaxevent->ies.capability,
IAX_SET) != SWITCH_STATUS_SUCCESS) {
iax_reject(iaxevent->session, "Codec Error!");
switch_core_session_destroy(&session);
} else {
tech_pvt->iax_session = iaxevent->session;
tech_pvt->session = session;
iax_accept(tech_pvt->iax_session, tech_pvt->codec);
iax_ring_announce(tech_pvt->iax_session);
switch_channel_set_state(channel, CS_INIT);
switch_core_session_thread_launch(session);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Session? %s\n", switch_test_flag(tech_pvt, TFLAG_VOICE) ? "yes" : "no");
}
}
}
break;
case IAX_EVENT_REJECT:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Rejected call.\n");
case IAX_EVENT_BUSY:
case IAX_EVENT_HANGUP:
if (tech_pvt) {
switch_channel *channel;
switch_clear_flag(tech_pvt, TFLAG_IO);
switch_clear_flag(tech_pvt, TFLAG_VOICE);
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hangup %s\n", switch_channel_get_name(channel));
switch_set_flag(tech_pvt, TFLAG_HANGUP);
switch_channel_hangup(channel);
break;
case IAX_EVENT_CNG:
// pseudo-silence
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sending silence\n");
break;
case IAX_EVENT_VOICE:
if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) {
int bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
int frames = (int)(tech_pvt->read_frame.datalen / bytes);
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
/* wake up the i/o thread*/
switch_set_flag(tech_pvt, TFLAG_VOICE);
switch_thread_cond_signal(tech_pvt->cond);
iaxevent->session = NULL;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "No Session? %s\n", switch_test_flag(tech_pvt, TFLAG_VOICE) ? "yes" : "no");
}
}
break;
case IAX_EVENT_CNG:
// pseudo-silence
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sending silence\n");
break;
case IAX_EVENT_VOICE:
if (tech_pvt && (tech_pvt->read_frame.datalen = iaxevent->datalen)) {
int bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
int frames = (int)(tech_pvt->read_frame.datalen / bytes);
tech_pvt->read_frame.samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
memcpy(tech_pvt->read_frame.data, iaxevent->data, iaxevent->datalen);
/* wake up the i/o thread*/
switch_set_flag(tech_pvt, TFLAG_VOICE);
switch_thread_cond_signal(tech_pvt->cond);
}
break;
case IAX_EVENT_TRANSFER:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call transfer occurred.\n");
//session[0] = iaxevent->session;
break;
case IAX_EVENT_DTMF:
if (tech_pvt) {
switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
char str[2] = {iaxevent->subclass};
if (globals.debug) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s DTMF %s\n", str, switch_channel_get_name(channel));
break;
case IAX_EVENT_TRANSFER:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Call transfer occurred.\n");
//session[0] = iaxevent->session;
break;
case IAX_EVENT_DTMF:
if (tech_pvt) {
switch_channel *channel;
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
char str[2] = {iaxevent->subclass};
if (globals.debug) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s DTMF %s\n", str, switch_channel_get_name(channel));
}
switch_channel_queue_dtmf(channel, str);
}
switch_channel_queue_dtmf(channel, str);
}
}
break;
default:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
break;
break;
default:
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Don't know what to do with IAX event %d.\n", iaxevent->etype);
break;
}
iax_event_free(iaxevent);

View File

@ -58,11 +58,11 @@ void playback_function(switch_core_session *session, char *data)
assert(channel != NULL);
if (switch_core_file_open(&fh,
data,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel);
return;
data,
SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_channel_hangup(channel);
return;
}
switch_channel_answer(channel);
@ -80,15 +80,15 @@ void playback_function(switch_core_session *session, char *data)
codec_name = "L16";
if (switch_core_codec_init(&codec,
codec_name,
fh.samplerate,
interval,
fh.channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
pool) == SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
write_frame.codec = &codec;
codec_name,
fh.samplerate,
interval,
fh.channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL,
pool) == SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
write_frame.codec = &codec;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activation Failed %s@%dhz %d channels %dms\n", codec_name, fh.samplerate, fh.channels, interval);
switch_core_file_close(&fh);
@ -188,8 +188,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
}
/* 'switch_module_runtime' will start up in a thread by itself just by having it exist
if it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
*/
if it returns anything but SWITCH_STATUS_TERM it will be called again automaticly
*/
//switch_status switch_module_runtime(void)

View File

@ -95,40 +95,6 @@ static switch_status switch_raw_destroy(switch_codec *codec)
return SWITCH_STATUS_SUCCESS;
}
#if 0
switch_status raw_file_open(switch_file_handle *handle, char *path)
{
return SWITCH_STATUS_SUCCESS;
}
switch_status raw_file_close(switch_file_handle *handle)
{
return SWITCH_STATUS_SUCCESS;
}
switch_status raw_file_seek(switch_file_handle *handle, unsigned int *cur_sample, unsigned int samples, int whence)
{
return SWITCH_STATUS_NOTIMPL;
}
/* Registration */
static char *supported_formats[] = {"raw", "r8k", NULL};
static const switch_file_interface raw_file_interface = {
/*.interface_name*/ "raw",
/*.file_open*/ raw_file_open,
/*.file_close*/ raw_file_close,
/*.file_read*/ NULL,
/*.file_write*/ NULL,
/*.file_seek*/ raw_file_seek,
/*.extens*/ supported_formats,
/*.next*/ NULL,
};
#endif
static const switch_codec_implementation raw_32k_implementation = {
/*.samples_per_second = */ 32000,
/*.bits_per_second = */ 512000,

View File

@ -150,7 +150,7 @@ struct private_object {
struct woomera_profile *profile;
char dest[WOOMERA_STRLEN];
int port;
struct timeval started;
switch_time_t started;
int timeout;
char dtmfbuf[WOOMERA_STRLEN];
switch_caller_profile *caller_profile;

View File

@ -163,9 +163,9 @@ 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_core_session *session,
switch_channel_state state,
switch_channel_flag flags)
{
assert(channel != NULL);
channel->state = state;
@ -278,104 +278,104 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
/* STUB for more dev
case CS_INIT:
switch(state) {
switch(state) {
case CS_NEW:
case CS_INIT:
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
case CS_DONE:
case CS_NEW:
case CS_INIT:
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
case CS_DONE:
default:
break;
}
break;
default:
break;
}
break;
*/
switch(last_state) {
case CS_NEW:
switch(state) {
default:
ok++;
break;
}
break;
case CS_NEW:
switch(state) {
default:
ok++;
break;
}
break;
case CS_INIT:
switch(state) {
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_INIT:
switch(state) {
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_LOOPBACK:
switch(state) {
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_LOOPBACK:
switch(state) {
case CS_TRANSMIT:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_TRANSMIT:
switch(state) {
case CS_LOOPBACK:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_TRANSMIT:
switch(state) {
case CS_LOOPBACK:
case CS_RING:
case CS_EXECUTE:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_RING:
switch(state) {
case CS_LOOPBACK:
case CS_EXECUTE:
case CS_HANGUP:
case CS_TRANSMIT:
ok++;
default:
break;
}
break;
case CS_RING:
switch(state) {
case CS_LOOPBACK:
case CS_EXECUTE:
case CS_HANGUP:
case CS_TRANSMIT:
ok++;
default:
break;
}
break;
case CS_EXECUTE:
switch(state) {
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_EXECUTE:
switch(state) {
case CS_LOOPBACK:
case CS_TRANSMIT:
case CS_RING:
case CS_HANGUP:
ok++;
default:
break;
}
break;
case CS_HANGUP:
switch(state) {
case CS_DONE:
ok++;
default:
break;
}
break;
case CS_HANGUP:
switch(state) {
case CS_DONE:
ok++;
default:
break;
}
break;
default:
break;
default:
break;
}

View File

@ -34,8 +34,8 @@
static int switch_console_process(char *cmd)
{
char *arg = NULL;
char retbuf[1024] = "";
char *arg = NULL;
char retbuf[1024] = "";
#ifdef EMBED_PERL
const char *perlhelp = "perl - execute some perl. (print to STDERR if you want to see it.)\n";
@ -48,12 +48,12 @@ char *arg = NULL;
}
if (!strcmp(cmd, "help")) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
"\n"
"Valid Commands:\n\n"
"help - umm yeah..\n"
"%sshutdown - stop the program\n\n",
perlhelp
);
"\n"
"Valid Commands:\n\n"
"help - umm yeah..\n"
"%sshutdown - stop the program\n\n",
perlhelp
);
return 1;
}
@ -119,14 +119,14 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel channel, char *fi
}
else if (channel == SWITCH_CHANNEL_ID_EVENT &&
switch_event_running() == SWITCH_STATUS_SUCCESS &&
switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
switch_event_running() == SWITCH_STATUS_SUCCESS &&
switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);
switch_event_fire(&event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);
switch_event_fire(&event);
}
free(data);
}

View File

@ -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++;
@ -350,9 +350,9 @@ SWITCH_DECLARE(switch_status) switch_core_file_open(switch_file_handle *fh, char
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);
@ -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;
@ -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,9 +1605,9 @@ 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");
@ -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);
@ -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;
}
}

View File

@ -84,7 +84,7 @@ static void *locked_dup(char *str)
#endif
/* make sure this is synced with the switch_event_t enum in switch_types.h
also never put any new ones before EVENT_ALL
also never put any new ones before EVENT_ALL
*/
static char *EVENT_NAMES[] = {
"CUSTOM",
@ -243,23 +243,23 @@ SWITCH_DECLARE(switch_status) switch_event_shutdown(void)
SWITCH_DECLARE(switch_status) switch_event_init(switch_memory_pool *pool)
{
switch_thread *thread;
switch_threadattr_t *thd_attr;;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_thread *thread;
switch_threadattr_t *thd_attr;;
switch_threadattr_create(&thd_attr, pool);
switch_threadattr_detach_set(thd_attr, 1);
assert(pool != NULL);
RUNTIME_POOL = pool;
if (switch_core_new_memory_pool(&APOOL) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
return SWITCH_STATUS_MEMERR;
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
return SWITCH_STATUS_MEMERR;
}
if (switch_core_new_memory_pool(&BPOOL) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
return SWITCH_STATUS_MEMERR;
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate memory pool\n");
return SWITCH_STATUS_MEMERR;
}
THRUNTIME_POOL = APOOL;
switch_queue_create(&EVENT_QUEUE, POOL_COUNT_MAX + 10, THRUNTIME_POOL);
@ -268,12 +268,12 @@ 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);
@ -321,10 +321,10 @@ SWITCH_DECLARE(char *) switch_event_get_header(switch_event *event, char *header
SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switch_stack_t stack, char *header_name, char *fmt, ...)
{
int ret = 0;
int ret = 0;
char data[2048];
va_list ap;
va_list ap;
va_start(ap, fmt);
vsnprintf(data, sizeof(data), fmt, ap);
va_end(ap);
@ -366,10 +366,10 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
SWITCH_DECLARE(switch_status) switch_event_add_body(switch_event *event, char *fmt, ...)
{
int ret = 0;
int ret = 0;
char data[2048];
va_list ap;
va_list ap;
va_start(ap, fmt);
vsnprintf(data, sizeof(data), fmt, ap);
va_end(ap);
@ -441,9 +441,9 @@ SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *
{
size_t len = 0;
switch_event_header *hp;
char *data = NULL, *body = NULL;
int ret = 0;
va_list ap;
char *data = NULL, *body = NULL;
int ret = 0;
va_list ap;
if (fmt) {
va_start(ap, fmt);

View File

@ -250,8 +250,8 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
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);
(char *) ptr->interface_name,
(void *) ptr);
}
}
@ -262,16 +262,16 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
for(ptr = new_module->interface->codec_interface; ptr; ptr = ptr->next) {
for(impl = ptr->implementations; impl ; impl = impl->next) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE,
"Adding Codec '%s' (%s) %dkhz %dms\n",
ptr->iananame,
ptr->interface_name,
impl->samples_per_second,
impl->microseconds_per_frame / 1000);
"Adding Codec '%s' (%s) %dkhz %dms\n",
ptr->iananame,
ptr->interface_name,
impl->samples_per_second,
impl->microseconds_per_frame / 1000);
}
switch_core_hash_insert(loadable_modules.codec_hash,
(char *) ptr->iananame,
(void *) ptr);
(char *) ptr->iananame,
(void *) ptr);
}
}
@ -281,8 +281,8 @@ 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);
(char *) ptr->interface_name,
(void *) ptr);
}
}
@ -292,8 +292,8 @@ 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);
(char *) ptr->interface_name,
(void *) ptr);
}
}
@ -303,8 +303,8 @@ 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,8 +314,8 @@ 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);
(char *) ptr->interface_name,
(void *) ptr);
}
}
@ -327,8 +327,8 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
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);
(char *) ptr->extens[i],
(void *) ptr);
}
}
}

View File

@ -32,8 +32,8 @@
#include <switch_mutex.h>
SWITCH_DECLARE(switch_status) switch_mutex_init(switch_mutex_t **lock,
switch_lock_flag flags,
switch_memory_pool *pool)
switch_lock_flag flags,
switch_memory_pool *pool)
{
return (apr_thread_mutex_create(lock, flags, pool) == APR_SUCCESS) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;

View File

@ -77,23 +77,23 @@ 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)
{
int o=0, srcused=0, srcpos=0, out=0;
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);
//printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
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);
//printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
srcpos += srcused;
if (o >= 0) {
out += o;
out += o;
}
if (o < 0 || (o == 0 && srcpos == srclen)) {
break;
break;
}
}
return out;
}
return out;
}
SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler)

View File

@ -72,21 +72,16 @@ SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll,
switch_pollset_t *pollset;
switch_status status;
if ((status = switch_pollset_create(&pollset, 1, pool, flags)) != SWITCH_STATUS_SUCCESS) {
return status;
}
poll->desc_type = SWITCH_POLL_SOCKET;
poll->reqevents = flags;
poll->desc.s = sock;
poll->client_data = sock;
return switch_pollset_add(pollset, poll);
}
@ -102,54 +97,6 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
return nsds;
}
#ifdef HAVE_TIMEVAL_STRUCT
#define ONE_MILLION 1000000
/*
* put timeval in a valid range. usec is 0..999999
* negative values are not allowed and truncated.
*/
static struct timeval tvfix(struct timeval a)
{
if (a.tv_usec >= ONE_MILLION) {
a.tv_sec += a.tv_usec % ONE_MILLION;
a.tv_usec %= ONE_MILLION;
} else if (a.tv_usec < 0) {
a.tv_usec = 0;
}
return a;
}
struct timeval switch_tvadd(struct timeval a, struct timeval b)
{
/* consistency checks to guarantee usec in 0..999999 */
a = tvfix(a);
b = tvfix(b);
a.tv_sec += b.tv_sec;
a.tv_usec += b.tv_usec;
if (a.tv_usec >= ONE_MILLION) {
a.tv_sec++;
a.tv_usec -= ONE_MILLION;
}
return a;
}
struct timeval switch_tvsub(struct timeval a, struct timeval b)
{
/* consistency checks to guarantee usec in 0..999999 */
a = tvfix(a);
b = tvfix(b);
a.tv_sec -= b.tv_sec;
a.tv_usec -= b.tv_usec;
if (a.tv_usec < 0) {
a.tv_sec-- ;
a.tv_usec += ONE_MILLION;
}
return a;
}
#undef ONE_MILLION
#endif
#ifdef WIN32
//this forces certain symbols to not be optimized out of the dll
void include_me(void)