提交 241903ba authored 作者: Michael Jerris's avatar Michael Jerris

fix more msvc warnings.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@636 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 70739b6d
...@@ -384,6 +384,7 @@ typedef apr_socket_t switch_socket_t; ...@@ -384,6 +384,7 @@ typedef apr_socket_t switch_socket_t;
/** Freeswitch's socket address type, used to ensure protocol independence */ /** Freeswitch's socket address type, used to ensure protocol independence */
typedef apr_sockaddr_t switch_sockaddr_t; typedef apr_sockaddr_t switch_sockaddr_t;
typedef apr_port_t switch_port_t;
/* function definitions */ /* function definitions */
/** /**
......
...@@ -39,7 +39,9 @@ extern "C" { ...@@ -39,7 +39,9 @@ extern "C" {
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4152 4054 4100) // C4200 Non standard extension C zero sized array
// C4204: nonstandard extension used : non-constant aggregate initializer
#pragma warning(disable:4152 4054 4100 4142 4200 4204)
#endif #endif
#if (_MSC_VER >= 1400) // VC8+ #if (_MSC_VER >= 1400) // VC8+
......
...@@ -69,7 +69,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) ...@@ -69,7 +69,7 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
memset(app, 0, sizeof(app)); memset(app, 0, sizeof(app));
strncpy(app, val, sizeof(app)); strncpy(app, val, sizeof(app));
if ((data = strchr(app, ' '))) { if ((data = strchr(app, ' ')) != 0) {
*data = '\0'; *data = '\0';
data++; data++;
} else { } else {
...@@ -77,10 +77,9 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session) ...@@ -77,10 +77,9 @@ switch_caller_extension *demo_dialplan_hunt(switch_core_session *session)
continue; continue;
} }
if (!extension) { if (!extension) {
if (! if ((extension =
(extension =
switch_caller_extension_new(session, caller_profile->destination_number, switch_caller_extension_new(session, caller_profile->destination_number,
caller_profile->destination_number))) { caller_profile->destination_number)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n");
break; break;
} }
......
...@@ -124,14 +124,14 @@ switch_caller_extension *directory_dialplan_hunt(switch_core_session *session) ...@@ -124,14 +124,14 @@ switch_caller_extension *directory_dialplan_hunt(switch_core_session *session)
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DIRECTORY VALUE [%s]=[%s]\n", var, val); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DIRECTORY VALUE [%s]=[%s]\n", var, val);
if(!strcasecmp(var, "callflow")) { if(!strcasecmp(var, "callflow")) {
if (!extension) { if (!extension) {
if (!(extension = switch_caller_extension_new(session, caller_profile->destination_number, if ((extension = switch_caller_extension_new(session, caller_profile->destination_number,
caller_profile->destination_number))) { caller_profile->destination_number)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n");
goto out; goto out;
} }
} }
switch_copy_string(app, val, sizeof(app)); switch_copy_string(app, val, sizeof(app));
if ((data = strchr(app, ' '))) { if ((data = strchr(app, ' ')) != 0) {
*data++ = '\0'; *data++ = '\0';
} }
switch_caller_extension_add_application(session, extension, app, data); switch_caller_extension_add_application(session, extension, app, data);
......
...@@ -144,15 +144,14 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session) ...@@ -144,15 +144,14 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
memset(app, 0, sizeof(app)); memset(app, 0, sizeof(app));
switch_copy_string(app, newval, sizeof(app)); switch_copy_string(app, newval, sizeof(app));
if ((data = strchr(app, ' '))) { if ((data = strchr(app, ' ')) != 0) {
*data = '\0'; *data = '\0';
data++; data++;
} }
if (!extension) { if (!extension) {
if (! if ((extension =
(extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
switch_caller_extension_new(session, exten_name, caller_profile->destination_number))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "memory error!\n");
break; break;
} }
......
...@@ -63,7 +63,7 @@ static switch_status mod_ldap_open(switch_directory_handle *dh, char *source, ch ...@@ -63,7 +63,7 @@ static switch_status mod_ldap_open(switch_directory_handle *dh, char *source, ch
int auth_method = LDAP_AUTH_SIMPLE; int auth_method = LDAP_AUTH_SIMPLE;
int desired_version = LDAP_VERSION3; int desired_version = LDAP_VERSION3;
if (!(context = switch_core_alloc(dh->memory_pool, sizeof(*context)))) { if ((context = switch_core_alloc(dh->memory_pool, sizeof(*context))) == 0) {
return SWITCH_STATUS_MEMERR; return SWITCH_STATUS_MEMERR;
} }
...@@ -188,7 +188,7 @@ switch_status mod_ldap_next_pair(switch_directory_handle *dh, char **var, char * ...@@ -188,7 +188,7 @@ switch_status mod_ldap_next_pair(switch_directory_handle *dh, char **var, char *
context->attr = ldap_next_attribute(context->ld, context->entry, context->ber); context->attr = ldap_next_attribute(context->ld, context->entry, context->ber);
} }
context->vitt++; context->vitt++;
if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr))) { if (context->entry && context->attr && (context->vals = ldap_get_values(context->ld, context->entry, context->attr)) != 0) {
goto itter; goto itter;
} }
} }
......
...@@ -70,9 +70,6 @@ typedef enum { ...@@ -70,9 +70,6 @@ typedef enum {
#define PACKET_LEN 160 #define PACKET_LEN 160
#define DEFAULT_BYTES_PER_FRAME 160 #define DEFAULT_BYTES_PER_FRAME 160
static const switch_endpoint_interface exosip_endpoint_interface;
static struct { static struct {
int debug; int debug;
int bytes_per_frame; int bytes_per_frame;
...@@ -288,9 +285,8 @@ static switch_status exosip_on_init(switch_core_session *session) ...@@ -288,9 +285,8 @@ static switch_status exosip_on_init(switch_core_session *session)
} }
/* Setup our INVITE */ /* Setup our INVITE */
eXosip_lock(); eXosip_lock();
if (! if ((dest_uri =
(dest_uri = (char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10)) == 0) {
(char *) switch_core_session_alloc(session, strlen(tech_pvt->caller_profile->destination_number) + 10))) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "AIEEEE!\n");
assert(dest_uri != NULL); assert(dest_uri != NULL);
} }
...@@ -380,51 +376,6 @@ static switch_status exosip_on_transmit(switch_core_session *session) ...@@ -380,51 +376,6 @@ static switch_status exosip_on_transmit(switch_core_session *session)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
switch_core_session **new_session)
{
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL))) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_core_session_set_private(*new_session, tech_pvt);
switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
tech_pvt->session = *new_session;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
if (outbound_profile) {
char name[128];
switch_caller_profile *caller_profile;
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
snprintf(name, sizeof(name), "Exosip/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_GENERR;
}
static void deactivate_rtp(struct private_object *tech_pvt) static void deactivate_rtp(struct private_object *tech_pvt)
{ {
...@@ -751,6 +702,51 @@ static const switch_loadable_module_interface exosip_module_interface = { ...@@ -751,6 +702,51 @@ static const switch_loadable_module_interface exosip_module_interface = {
/*.application_interface */ NULL /*.application_interface */ NULL
}; };
static switch_status exosip_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
switch_core_session **new_session)
{
if ((*new_session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_core_session_set_private(*new_session, tech_pvt);
switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
tech_pvt->session = *new_session;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
if (outbound_profile) {
char name[128];
switch_caller_profile *caller_profile;
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
snprintf(name, sizeof(name), "Exosip/%s-%04x", caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_GENERR;
}
#if 1 #if 1
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void) SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
{ {
...@@ -792,13 +788,13 @@ static switch_status exosip_create_call(eXosip_event_t * event) ...@@ -792,13 +788,13 @@ static switch_status exosip_create_call(eXosip_event_t * event)
char *dpayload, *dname, *drate; char *dpayload, *dname, *drate;
char *remote_sdp_str = NULL; char *remote_sdp_str = NULL;
if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL))) { if ((session = switch_core_session_request(&exosip_endpoint_interface, NULL)) != 0) {
struct private_object *tech_pvt; struct private_object *tech_pvt;
switch_codec_interface *codecs[SWITCH_MAX_CODECS]; switch_codec_interface *codecs[SWITCH_MAX_CODECS];
int num_codecs = 0; int num_codecs = 0;
switch_core_session_add_stream(session, NULL); switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) { if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
memset(tech_pvt, 0, sizeof(*tech_pvt)); memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
...@@ -815,7 +811,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) ...@@ -815,7 +811,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
event->request->from->displayname, event->request->from->displayname,
event->request->from->url->username, event->request->from->url->username,
event->request->from->url->host, event->request->from->url->host,
NULL, NULL, event->request->req_uri->username))) { NULL, NULL, event->request->req_uri->username)) != 0) {
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
} }
...@@ -827,7 +823,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) ...@@ -827,7 +823,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
snprintf(name, sizeof(name), "Exosip/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff); snprintf(name, sizeof(name), "Exosip/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name); switch_channel_set_name(channel, name);
if (!(remote_sdp = eXosip_get_sdp_info(event->request))) { if ((remote_sdp = eXosip_get_sdp_info(event->request)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Remote SDP!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Remote SDP!\n");
exosip_on_hangup(session); exosip_on_hangup(session);
switch_core_session_destroy(&session); switch_core_session_destroy(&session);
...@@ -915,7 +911,7 @@ static switch_status exosip_create_call(eXosip_event_t * event) ...@@ -915,7 +911,7 @@ static switch_status exosip_create_call(eXosip_event_t * event)
switch_channel_set_state(channel, CS_INIT); switch_channel_set_state(channel, CS_INIT);
if (1) { {
int rate = atoi(drate); int rate = atoi(drate);
if (switch_core_codec_init(&tech_pvt->read_codec, if (switch_core_codec_init(&tech_pvt->read_codec,
...@@ -975,7 +971,7 @@ static void destroy_call_by_event(eXosip_event_t * event) ...@@ -975,7 +971,7 @@ static void destroy_call_by_event(eXosip_event_t * event)
struct private_object *tech_pvt; struct private_object *tech_pvt;
switch_channel *channel = NULL; switch_channel *channel = NULL;
if (!(tech_pvt = get_pvt_by_call_id(event->cid))) { if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n", switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt [%d]!\n",
event->cid); event->cid);
return; return;
...@@ -1001,12 +997,12 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d ...@@ -1001,12 +997,12 @@ static switch_status parse_sdp_media(sdp_media_t * media, char **dname, char **d
attr = (sdp_attribute_t *) osip_list_get(media->a_attributes, pos); attr = (sdp_attribute_t *) osip_list_get(media->a_attributes, pos);
if (attr != NULL && strcasecmp(attr->a_att_field, "rtpmap") == 0) { if (attr != NULL && strcasecmp(attr->a_att_field, "rtpmap") == 0) {
payload = attr->a_att_value; payload = attr->a_att_value;
if ((name = strchr(payload, ' '))) { if ((name = strchr(payload, ' ')) != 0) {
*(name++) = '\0'; *(name++) = '\0';
/* Name and payload are required */ /* Name and payload are required */
*dpayload = strdup(payload); *dpayload = strdup(payload);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
if ((rate = strchr(name, '/'))) { if ((rate = strchr(name, '/')) != 0) {
*(rate++) = '\0'; *(rate++) = '\0';
*drate = strdup(rate); *drate = strdup(rate);
*dname = strdup(name); *dname = strdup(name);
...@@ -1041,7 +1037,7 @@ static void handle_answer(eXosip_event_t * event) ...@@ -1041,7 +1037,7 @@ static void handle_answer(eXosip_event_t * event)
switch_channel *channel; switch_channel *channel;
if (!(tech_pvt = get_pvt_by_call_id(event->cid))) { if ((tech_pvt = get_pvt_by_call_id(event->cid)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt!\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Um in case you are interested, Can't find the pvt!\n");
return; return;
} }
...@@ -1056,7 +1052,7 @@ static void handle_answer(eXosip_event_t * event) ...@@ -1056,7 +1052,7 @@ static void handle_answer(eXosip_event_t * event)
} }
/* Get all of the remote SDP elements... stuff */ /* Get all of the remote SDP elements... stuff */
if (!(remote_sdp = eXosip_get_sdp_info(event->response))) { if ((remote_sdp = eXosip_get_sdp_info(event->response)) == 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cant Find SDP?\n"); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cant Find SDP?\n");
switch_channel_hangup(channel); switch_channel_hangup(channel);
return; return;
...@@ -1080,7 +1076,7 @@ static void handle_answer(eXosip_event_t * event) ...@@ -1080,7 +1076,7 @@ static void handle_answer(eXosip_event_t * event)
tech_pvt->tid = event->tid; tech_pvt->tid = event->tid;
if (1) { {
int rate = atoi(drate); int rate = atoi(drate);
...@@ -1348,7 +1344,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -1348,7 +1344,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
globals.running = 1; globals.running = 1;
while (globals.running > 0) { while (globals.running > 0) {
if (!(event = eXosip_event_wait(0, 100))) { if ((event = eXosip_event_wait(0, 100)) == 0) {
switch_yield(1000); switch_yield(1000);
continue; continue;
} }
......
...@@ -201,6 +201,22 @@ ...@@ -201,6 +201,22 @@
<File <File
RelativePath="..\..\..\..\libs\osip\src\osipparser2\osip_rfc3264.c" RelativePath="..\..\..\..\libs\osip\src\osipparser2\osip_rfc3264.c"
> >
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
WarningLevel="3"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
WarningLevel="3"
/>
</FileConfiguration>
</File> </File>
</Filter> </Filter>
<Filter <Filter
......
...@@ -98,9 +98,6 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan) ...@@ -98,9 +98,6 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_name, globals.cid_name)
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num) SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_cid_num, globals.cid_num)
static const switch_endpoint_interface channel_endpoint_interface;
static switch_status channel_on_init(switch_core_session *session); static switch_status channel_on_init(switch_core_session *session);
static switch_status channel_on_hangup(switch_core_session *session); static switch_status channel_on_hangup(switch_core_session *session);
static switch_status channel_on_ring(switch_core_session *session); static switch_status channel_on_ring(switch_core_session *session);
...@@ -294,55 +291,6 @@ static switch_status channel_on_transmit(switch_core_session *session) ...@@ -294,55 +291,6 @@ 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!
*/
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
switch_core_session **new_session)
{
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_caller_profile *caller_profile;
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object)))) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_core_session_set_private(*new_session, tech_pvt);
tech_pvt->session = *new_session;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
if (outbound_profile) {
char name[128];
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
caller_profile->destination_number ? caller_profile->destination_number : modname,
rand() & 0xffff);
switch_channel_set_name(channel, name);
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_GENERR;
}
static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id) static switch_status channel_waitfor_read(switch_core_session *session, int ms, int stream_id)
{ {
struct private_object *tech_pvt = NULL; struct private_object *tech_pvt = NULL;
...@@ -399,7 +347,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra ...@@ -399,7 +347,7 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
if (tech_pvt->audio_in && if (tech_pvt->audio_in &&
(samples = (samples =
ReadAudioStream(tech_pvt->audio_in, tech_pvt->read_frame.data, ReadAudioStream(tech_pvt->audio_in, tech_pvt->read_frame.data,
tech_pvt->read_codec.implementation->samples_per_frame))) { tech_pvt->read_codec.implementation->samples_per_frame)) != 0) {
tech_pvt->read_frame.datalen = samples * 2; tech_pvt->read_frame.datalen = samples * 2;
tech_pvt->read_frame.samples = samples; tech_pvt->read_frame.samples = samples;
*frame = &tech_pvt->read_frame; *frame = &tech_pvt->read_frame;
...@@ -524,7 +472,54 @@ static const switch_loadable_module_interface channel_module_interface = { ...@@ -524,7 +472,54 @@ static const switch_loadable_module_interface channel_module_interface = {
/*.api_interface */ &channel_api_interface /*.api_interface */ &channel_api_interface
}; };
/* 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!
*/
static switch_status channel_outgoing_channel(switch_core_session *session, switch_caller_profile *outbound_profile,
switch_core_session **new_session)
{
if ((*new_session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
struct private_object *tech_pvt;
switch_channel *channel;
switch_caller_profile *caller_profile;
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
(struct private_object *) switch_core_session_alloc(*new_session, sizeof(struct private_object))) != 0) {
memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(*new_session);
switch_core_session_set_private(*new_session, tech_pvt);
tech_pvt->session = *new_session;
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
if (outbound_profile) {
char name[128];
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
snprintf(name, sizeof(name), "PortAudio/%s-%04x",
caller_profile->destination_number ? caller_profile->destination_number : modname,
rand() & 0xffff);
switch_channel_set_name(channel, name);
} else {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Doh! no caller profile\n");
switch_core_session_destroy(new_session);
return SWITCH_STATUS_GENERR;
}
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
return SWITCH_STATUS_SUCCESS;
}
return SWITCH_STATUS_GENERR;
}
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename)
...@@ -796,12 +791,12 @@ static switch_status place_call(char *dest, char *out, size_t outlen) ...@@ -796,12 +791,12 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
strncpy(out, "FAIL", outlen - 1); strncpy(out, "FAIL", outlen - 1);
if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) { if ((session = switch_core_session_request(&channel_endpoint_interface, NULL)) != 0) {
struct private_object *tech_pvt; struct private_object *tech_pvt;
switch_channel *channel; switch_channel *channel;
switch_core_session_add_stream(session, NULL); switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) { if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object))) != 0) {
memset(tech_pvt, 0, sizeof(*tech_pvt)); memset(tech_pvt, 0, sizeof(*tech_pvt));
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
switch_core_session_set_private(session, tech_pvt); switch_core_session_set_private(session, tech_pvt);
...@@ -815,7 +810,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen) ...@@ -815,7 +810,7 @@ static switch_status place_call(char *dest, char *out, size_t outlen)
if ((tech_pvt->caller_profile = switch_caller_profile_new(session, if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
globals.dialplan, globals.dialplan,
globals.cid_name, globals.cid_name,
globals.cid_num, NULL, NULL, NULL, dest))) { globals.cid_num, NULL, NULL, NULL, dest)) != 0) {
char name[128]; char name[128];
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
snprintf(name, sizeof(name), "PortAudio/%s-%04x", snprintf(name, sizeof(name), "PortAudio/%s-%04x",
...@@ -863,7 +858,7 @@ static switch_status hup_call(char *callid, char *out, size_t outlen) ...@@ -863,7 +858,7 @@ static switch_status hup_call(char *callid, char *out, size_t outlen)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
channel = switch_core_session_get_channel(tech_pvt->session); channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL); assert(channel != NULL);
...@@ -884,13 +879,13 @@ static switch_status send_dtmf(char *callid, char *out, size_t outlen) ...@@ -884,13 +879,13 @@ static switch_status send_dtmf(char *callid, char *out, size_t outlen)
switch_channel *channel = NULL; switch_channel *channel = NULL;
char *dtmf; char *dtmf;
if ((dtmf = strchr(callid, ' '))) { if ((dtmf = strchr(callid, ' ')) != 0) {
*dtmf++ = '\0'; *dtmf++ = '\0';
} else { } else {
dtmf = ""; dtmf = "";
} }
if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
channel = switch_core_session_get_channel(tech_pvt->session); channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL); assert(channel != NULL);
switch_channel_queue_dtmf(channel, dtmf); switch_channel_queue_dtmf(channel, dtmf);
...@@ -907,7 +902,7 @@ static switch_status answer_call(char *callid, char *out, size_t outlen) ...@@ -907,7 +902,7 @@ static switch_status answer_call(char *callid, char *out, size_t outlen)
struct private_object *tech_pvt = NULL; struct private_object *tech_pvt = NULL;
switch_channel *channel = NULL; switch_channel *channel = NULL;
if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
channel = switch_core_session_get_channel(tech_pvt->session); channel = switch_core_session_get_channel(tech_pvt->session);
assert(channel != NULL); assert(channel != NULL);
switch_set_flag(tech_pvt, TFLAG_ANSWER); switch_set_flag(tech_pvt, TFLAG_ANSWER);
...@@ -945,7 +940,7 @@ static switch_status call_info(char *callid, char *out, size_t outlen) ...@@ -945,7 +940,7 @@ static switch_status call_info(char *callid, char *out, size_t outlen)
tech_pvt = val; tech_pvt = val;
print_info(tech_pvt, out + strlen(out), outlen - strlen(out)); print_info(tech_pvt, out + strlen(out), outlen - strlen(out));
} }
} else if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid))) { } else if ((tech_pvt = switch_core_hash_find(globals.call_hash, callid)) != 0) {
print_info(tech_pvt, out, outlen); print_info(tech_pvt, out, outlen);
} else { } else {
strncpy(out, "NO SUCH CALL", outlen - 1); strncpy(out, "NO SUCH CALL", outlen - 1);
......
...@@ -37,7 +37,7 @@ static switch_memory_pool *module_pool; ...@@ -37,7 +37,7 @@ static switch_memory_pool *module_pool;
static struct { static struct {
char *address; char *address;
int port; switch_port_t port;
switch_sockaddr_t *addr; switch_sockaddr_t *addr;
switch_socket_t *udp_socket; switch_socket_t *udp_socket;
int running; int running;
...@@ -70,7 +70,7 @@ static switch_status load_config(void) ...@@ -70,7 +70,7 @@ static switch_status load_config(void)
if (!strcasecmp(var, "address")) { if (!strcasecmp(var, "address")) {
set_global_address(val); set_global_address(val);
} else if (!strcasecmp(var, "port")) { } else if (!strcasecmp(var, "port")) {
globals.port = atoi(val); globals.port = (switch_port_t)atoi(val);
} }
} }
} }
...@@ -205,13 +205,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -205,13 +205,13 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes"); switch_event_add_header(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes");
var = buf; var = buf;
while(*var) { while(*var) {
if ((val = strchr(var, ':'))) { if ((val = strchr(var, ':')) != 0) {
char varname[512]; char varname[512];
*val++ = '\0'; *val++ = '\0';
while(*val == ' ') { while(*val == ' ') {
val++; val++;
} }
if ((term = strchr(val, '\r')) || (term=strchr(val, '\n'))) { if ((term = strchr(val, '\r')) != 0 || (term=strchr(val, '\n')) != 0) {
*term = '\0'; *term = '\0';
while(*term == '\r' || *term == '\n') { while(*term == '\r' || *term == '\n') {
term++; term++;
......
...@@ -223,13 +223,13 @@ int on_msg(void *user_data, ikspak * pak) ...@@ -223,13 +223,13 @@ int on_msg(void *user_data, ikspak * pak)
char retbuf[1024] = ""; char retbuf[1024] = "";
char *p; char *p;
if ((p = strchr(cmd, '\r'))) { if ((p = strchr(cmd, '\r')) != 0) {
*p++ = '\0'; *p++ = '\0';
} else if ((p = strchr(cmd, '\n'))) { } else if ((p = strchr(cmd, '\n')) != 0) {
*p++ = '\0'; *p++ = '\0';
} }
if ((arg = strchr(cmd, ' '))) { if ((arg = strchr(cmd, ' ')) != 0) {
*arg++ = '\0'; *arg++ = '\0';
} }
......
...@@ -135,9 +135,9 @@ static void event_handler(switch_event *event) ...@@ -135,9 +135,9 @@ static void event_handler(switch_event *event)
switch_event_header *hp; switch_event_header *hp;
char *service = switch_event_get_header(event, "service"); char *service = switch_event_get_header(event, "service");
char *port = switch_event_get_header(event, "port"); char *port = switch_event_get_header(event, "port");
int porti = 0; sw_port porti = 0;
for (hp = event->headers; hp; hp = hp->next) { for (hp = event->headers; hp; hp = hp->next) {
int len = strlen(hp->name) + strlen(hp->value) + 2; size_t len = strlen(hp->name) + strlen(hp->value) + 2;
char *data = malloc(len); char *data = malloc(len);
if (!data) { if (!data) {
...@@ -156,7 +156,7 @@ static void event_handler(switch_event *event) ...@@ -156,7 +156,7 @@ static void event_handler(switch_event *event)
service = "_freeswitch._tcp"; service = "_freeswitch._tcp";
} }
if (port) { if (port) {
porti = atoi(port); porti = (sw_port)atoi(port);
} }
switch_mutex_lock(globals.zc_lock); switch_mutex_lock(globals.zc_lock);
...@@ -208,7 +208,7 @@ static switch_status load_config(void) ...@@ -208,7 +208,7 @@ static switch_status load_config(void)
while (switch_config_next_pair(&cfg, &var, &val)) { while (switch_config_next_pair(&cfg, &var, &val)) {
if (!strcasecmp(cfg.category, "settings")) { if (!strcasecmp(cfg.category, "settings")) {
if (!strcmp(var, "browse")) { if (!strcmp(var, "browse")) {
if ((oid = switch_core_alloc(module_pool, sizeof(*oid)))) { if ((oid = switch_core_alloc(module_pool, sizeof(*oid))) != 0) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bind browser to to %s\n", val); switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bind browser to to %s\n", val);
switch_mutex_lock(globals.zc_lock); switch_mutex_lock(globals.zc_lock);
sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid); sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid);
...@@ -308,7 +308,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void) ...@@ -308,7 +308,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
RUNNING = 1; RUNNING = 1;
while(RUNNING == 1) { while(RUNNING == 1) {
unsigned int ms; sw_uint32 ms;
ms = 100; ms = 100;
sw_discovery_step(globals.discovery, &ms); sw_discovery_step(globals.discovery, &ms);
switch_yield(1000); switch_yield(1000);
......
...@@ -425,14 +425,14 @@ SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void ...@@ -425,14 +425,14 @@ SWITCH_DECLARE(switch_status) switch_core_file_read(switch_file_handle *fh, void
{ {
assert(fh != NULL); assert(fh != NULL);
return fh->file_interface->file_read(fh, data, (unsigned int *) len); return fh->file_interface->file_read(fh, data, len);
} }
SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len) SWITCH_DECLARE(switch_status) switch_core_file_write(switch_file_handle *fh, void *data, size_t *len)
{ {
assert(fh != NULL); assert(fh != NULL);
return fh->file_interface->file_write(fh, data, (unsigned int *) len); return fh->file_interface->file_write(fh, data, len);
} }
SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples, SWITCH_DECLARE(switch_status) switch_core_file_seek(switch_file_handle *fh, unsigned int *cur_pos, unsigned int samples,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论