提交 bedcabb8 authored 作者: Michael Jerris's avatar Michael Jerris

cleanup and formating

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@261 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 900c0857
......@@ -37,7 +37,7 @@ extern "C" {
RTPIPv4Address addr(destip, tx_port);
RTPSessionParams sessparams;
int status;
#ifdef WIN32
if (!WSOCKON) {
WSADATA dat;
......@@ -70,13 +70,13 @@ extern "C" {
jrtp4c->transparams->SetPortbase(rx_port);
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) {
......@@ -128,7 +128,7 @@ extern "C" {
return 0;
}
if ((pack = jrtp4c->session->GetNextPacket())) {
slen = (int)pack->GetPayloadLength();
......
......@@ -43,10 +43,10 @@ static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flag
{
struct gsm_context *context;
int encoding, decoding;
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
if (!(encoding || decoding)) {
return SWITCH_STATUS_FALSE;
} else {
......@@ -56,9 +56,9 @@ static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flag
}
codec->private = context;
return SWITCH_STATUS_SUCCESS;
}
static switch_status switch_gsm_destroy(switch_codec *codec)
......@@ -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,17 +116,17 @@ 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;
if (!context) {
return SWITCH_STATUS_FALSE;
}
......@@ -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;
}
......@@ -153,7 +153,7 @@ static switch_status switch_gsm_decode(switch_codec *codec,
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
}
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -50,7 +50,7 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
switch_channel *chan_a, *chan_b;
switch_frame *read_frame;
switch_core_session *session_a, *session_b;
session_a = data->objs[0];
session_b = data->objs[1];
......@@ -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)) {
......@@ -110,7 +110,7 @@ static switch_status audio_bridge_on_hangup(switch_core_session *session)
switch_core_session_kill_channel(other_session, SWITCH_SIG_KILL);
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
return SWITCH_STATUS_SUCCESS;
}
......@@ -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,16 +171,16 @@ 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);
if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session) != SWITCH_STATUS_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DOH!\n");
switch_channel_hangup(caller_channel);
......@@ -188,18 +188,18 @@ static void audio_bridge_function(switch_core_session *session, char *data)
} else {
struct switch_core_thread_session this_audio_thread, other_audio_thread;
time_t start;
peer_channel = switch_core_session_get_channel(peer_session);
memset(&other_audio_thread, 0, sizeof(other_audio_thread));
memset(&this_audio_thread, 0, sizeof(this_audio_thread));
other_audio_thread.objs[0] = session;
other_audio_thread.objs[1] = peer_session;
other_audio_thread.running = 5;
this_audio_thread.objs[0] = peer_session;
this_audio_thread.objs[1] = session;
this_audio_thread.running = 2;
switch_channel_set_private(caller_channel, peer_session);
switch_channel_set_private(peer_channel, session);
......@@ -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)) {
......@@ -262,7 +262,7 @@ static const switch_loadable_module_interface mod_bridgecall_module_interface =
};
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
/* connect my internal structure to the blank pointer passed to me */
*interface = &mod_bridgecall_module_interface;
......
......@@ -43,10 +43,10 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla
{
struct g729_context *context = NULL;
int encoding, decoding;
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(struct g729_context))))) {
return SWITCH_STATUS_FALSE;
} else {
......@@ -58,7 +58,7 @@ static switch_status switch_g729_init(switch_codec *codec, switch_codec_flag fla
}
codec->private = context;
return SWITCH_STATUS_SUCCESS;
}
}
......@@ -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;
......@@ -92,7 +92,7 @@ static switch_status switch_g729_encode(switch_codec *codec,
char *edp = encoded_data;
int x;
int loops = (int) decoded_data_len / 160;
for(x = 0; x < loops && new_len < *encoded_data_len; x++) {
g729_coder(&context->encoder_object, ddp, edp, &cbret);
edp += 10;
......@@ -111,17 +111,17 @@ 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;
if (!context) {
return SWITCH_STATUS_FALSE;
}
......@@ -148,8 +148,8 @@ static switch_status switch_g729_decode(switch_codec *codec,
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
}
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -59,7 +59,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
switch_channel_hangup(channel);
return NULL;
}
while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "extensions")) {
if (!strcmp(var, caller_profile->destination_number) && val) {
......@@ -67,7 +67,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
memset(app, 0, sizeof(app));
strncpy(app, val, sizeof(app));
if ((data = strchr(app, ' '))) {
*data = '\0';
data++;
......@@ -94,7 +94,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
} else {
switch_channel_hangup(channel);
}
return extension;
}
......@@ -115,14 +115,10 @@ static const switch_loadable_module_interface demo_dialplan_module_interface = {
};
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
/* connect my internal structure to the blank pointer passed to me */
*interface = &demo_dialplan_module_interface;
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
......@@ -47,7 +47,7 @@ static void event_handler (switch_event *event)
break;
}
}
static switch_loadable_module_interface event_test_module_interface = {
/*.module_name*/ modname,
......
......@@ -39,7 +39,7 @@ static const char modname[] = "mod_g711codec";
static switch_status switch_g711u_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
{
int encoding, decoding;
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
......@@ -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;
......@@ -67,25 +67,25 @@ static switch_status switch_g711u_encode(switch_codec *codec,
dbuf = decoded_data;
ebuf = encoded_data;
for (i = 0; i < decoded_data_len / sizeof(short); i++) {
ebuf[i] = linear2ulaw(dbuf[i]);
}
*encoded_data_len = i;
return SWITCH_STATUS_SUCCESS;
}
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;
......@@ -117,7 +117,7 @@ static switch_status switch_g711u_destroy(switch_codec *codec)
static switch_status switch_g711a_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
{
int encoding, decoding;
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
......@@ -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;
......@@ -145,25 +145,25 @@ static switch_status switch_g711a_encode(switch_codec *codec,
dbuf = decoded_data;
ebuf = encoded_data;
for (i = 0; i < decoded_data_len / sizeof(short); i++) {
ebuf[i] = linear2alaw(dbuf[i]);
}
*encoded_data_len = i;
return SWITCH_STATUS_SUCCESS;
}
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;
......
......@@ -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);
......@@ -70,25 +70,25 @@ void playback_function(switch_core_session *session, char *data)
write_frame.data = buf;
write_frame.buflen = sizeof(buf);
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OPEN FILE %s %dhz %d channels\n", data, fh.samplerate, fh.channels);
interval = 20;
samples = (fh.samplerate / 50) * fh.channels;
len = samples * 2;
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);
......@@ -115,7 +115,7 @@ void playback_function(switch_core_session *session, char *data)
if (switch_channel_has_dtmf(channel)) {
switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DTMF [%s]\n", dtmf);
switch (*dtmf) {
case '*':
done = 1;
......@@ -124,17 +124,17 @@ void playback_function(switch_core_session *session, char *data)
break;
}
}
if (done) {
break;
}
switch_core_file_read(&fh, buf, &ilen);
if (ilen <= 0) {
break;
}
write_frame.datalen = ilen * 2;
write_frame.samples = (int)ilen;
#ifdef SWAP_LINEAR
......@@ -149,7 +149,7 @@ void playback_function(switch_core_session *session, char *data)
break;
}
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "done playing file\n");
switch_core_file_close(&fh);
......@@ -178,7 +178,7 @@ static const switch_loadable_module_interface mod_playback_module_interface = {
};
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
/* connect my internal structure to the blank pointer passed to me */
*interface = &mod_playback_module_interface;
......@@ -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)
......
......@@ -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,
......
......@@ -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;
......
......@@ -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) {
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;
*/
switch(state) {
switch(last_state) {
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_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_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_HANGUP:
switch(state) {
case CS_DONE:
ok++;
default:
break;
}
break;
case CS_DONE:
default:
break;
break;
}
break;
*/
switch(last_state) {
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_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_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_HANGUP:
switch(state) {
case CS_DONE:
ok++;
default:
break;
}
break;
default:
break;
}
......@@ -406,7 +406,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
caller_profile = switch_channel_get_caller_profile(channel);
originator_caller_profile = switch_channel_get_originator_caller_profile(channel);
originatee_caller_profile = switch_channel_get_originatee_caller_profile(channel);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", (char *) switch_channel_state_name(channel->state));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
......@@ -416,7 +416,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
if (caller_profile) {
switch_caller_profile_event_set_data(caller_profile, "Caller", event);
}
/* Index Originator's Profile */
if (originator_caller_profile) {
switch_caller_profile_event_set_data(originator_caller_profile, "Originator", event);
......
......@@ -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_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_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);
}
free(data);
}
......
差异被折叠。
......@@ -76,7 +76,7 @@ static void *locked_dup(char *str)
dup = switch_core_strdup(THRUNTIME_POOL, str);
switch_mutex_unlock(POOL_LOCK);
/* </LOCKED> ----------------------------------------------*/
return dup;
}
#define ALLOC(size) locked_alloc(size)
......@@ -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",
......@@ -106,7 +106,7 @@ static int switch_events_match(switch_event *event, switch_event_node *node)
{
int match = 0;
if (node->event_id == SWITCH_EVENT_ALL) {
match++;
......@@ -178,7 +178,7 @@ static void * SWITCH_THREAD_FUNC switch_event_thread(switch_thread *thread, void
node->callback(out_event);
}
}
if (e == SWITCH_EVENT_ALL) {
break;
}
......@@ -224,9 +224,9 @@ SWITCH_DECLARE(switch_status) switch_event_reserve_subclass_detailed(char *owner
subclass->owner = switch_core_strdup(RUNTIME_POOL, owner);
subclass->name = switch_core_strdup(RUNTIME_POOL, subclass_name);
switch_core_hash_insert(CUSTOM_HASH, subclass->name, subclass);
return SWITCH_STATUS_SUCCESS;
}
......@@ -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);
......@@ -333,7 +333,7 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
return SWITCH_STATUS_MEMERR;
} else {
switch_event_header *header, *hp;
if (!(header = ALLOC(sizeof(*header)))) {
return SWITCH_STATUS_MEMERR;
}
......@@ -348,7 +348,7 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
event->headers = header;
} else {
for (hp = event->headers; hp && hp->next; hp = hp->next);
if (hp) {
hp->next = header;
} else {
......@@ -358,18 +358,18 @@ SWITCH_DECLARE(switch_status) switch_event_add_header(switch_event *event, switc
return SWITCH_STATUS_SUCCESS;
}
return (ret >= 0) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
}
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);
......@@ -380,9 +380,9 @@ SWITCH_DECLARE(switch_status) switch_event_add_body(switch_event *event, char *f
event->body = DUP(data);
return SWITCH_STATUS_SUCCESS;
}
return (ret >= 0) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
}
SWITCH_DECLARE(void) switch_event_destroy(switch_event **event)
......@@ -410,11 +410,11 @@ SWITCH_DECLARE(switch_status) switch_event_dup(switch_event **event, switch_even
if (switch_event_create_subclass(event, todup->event_id, todup->subclass->name) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_GENERR;
}
(*event)->subclass = todup->subclass;
(*event)->event_user_data = todup->event_user_data;
(*event)->bind_user_data = todup->bind_user_data;
for (hp = todup->headers; hp && hp->next;) {
if (!(header = ALLOC(sizeof(*header)))) {
return SWITCH_STATUS_MEMERR;
......@@ -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);
......@@ -462,7 +462,7 @@ SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *
for (hp = event->headers; hp; hp = hp->next) {
snprintf(buf+len, buflen-len, "%s: %s\n", hp->name, hp->value);
len = strlen(buf);
}
if (data) {
......@@ -485,7 +485,7 @@ SWITCH_DECLARE(switch_status) switch_event_serialize(switch_event *event, char *
if (data) {
free(data);
}
return SWITCH_STATUS_SUCCESS;
}
......@@ -499,7 +499,7 @@ SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func,
assert(BLOCK != NULL);
assert(RUNTIME_POOL != NULL);
if (THREAD_RUNNING <= 0) {
/* sorry we're closed */
switch_event_destroy(event);
......@@ -525,7 +525,7 @@ SWITCH_DECLARE(switch_status) switch_event_fire_detailed(char *file, char *func,
if (user_data) {
(*event)->event_user_data = user_data;
}
switch_queue_push(EVENT_QUEUE, *event);
*event = NULL;
......
......@@ -232,7 +232,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
if (!(ptr = (char *) fname)) {
continue;
}
if (!strstr(fname, ext) && !strstr(fname, EXT)) {
continue;
}
......@@ -250,11 +250,11 @@ 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);
}
}
if (new_module->interface->codec_interface) {
const switch_codec_implementation *impl;
const switch_codec_interface *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);
}
}
}
......
......@@ -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;
......
......@@ -54,7 +54,7 @@ SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **ne
switch_memory_pool *pool)
{
switch_audio_resampler *resampler;
if (!(resampler = switch_core_alloc(pool, sizeof(*resampler)))) {
return SWITCH_STATUS_MEMERR;
}
......@@ -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)
......
......@@ -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);
}
......@@ -94,61 +89,13 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
{
switch_status status;
int nsds = 0;
if ((status = switch_poll(poll, 1, &nsds, ms)) != SWITCH_STATUS_SUCCESS) {
return -1;
}
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;
return nsds;
}
#undef ONE_MILLION
#endif
#ifdef WIN32
//this forces certain symbols to not be optimized out of the dll
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论