From bfb6a8b1f5f835008d1e0fbd90d2e120814f341a Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 20 May 2010 23:19:10 +0200 Subject: [PATCH] Skinny: Initial Windows support Thanks to Peter Olsson Closes: MODSKINNY-3 --- Freeswitch.2008.sln | 13 +++++++++++++ src/mod/endpoints/mod_skinny/mod_skinny.c | 10 ++++++---- src/mod/endpoints/mod_skinny/skinny_server.c | 7 ++++++- src/mod/endpoints/mod_skinny/skinny_tables.h | 11 +++++++---- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Freeswitch.2008.sln b/Freeswitch.2008.sln index 506e227696..2126cb2152 100644 --- a/Freeswitch.2008.sln +++ b/Freeswitch.2008.sln @@ -947,6 +947,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_opal", "src\mod\endpoin {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_skinny", "src\mod\endpoints\mod_skinny\mod_skinny_2008.vcproj", "{CC1DD008-9406-448d-A0AD-33C3186CFADB}" + ProjectSection(ProjectDependencies) = postProject + {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_at_dictionary", "libs\spandsp\src\msvc\make_at_dictionary.2008.vcproj", "{DEE932AB-5911-4700-9EEB-8C7090A0A330}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_modem_filter", "libs\spandsp\src\msvc\make_modem_filter.2008.vcproj", "{329A6FA0-0FCC-4435-A950-E670AEFA9838}" @@ -2394,6 +2399,13 @@ Global {05C9FB27-480E-4D53-B3B7-6338E2526666}.Debug|x64.ActiveCfg = Debug|Win32 {05C9FB27-480E-4D53-B3B7-6338E2526666}.Release|Win32.ActiveCfg = Release|Win32 {05C9FB27-480E-4D53-B3B7-6338E2526666}.Release|x64.ActiveCfg = Release|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.All|Win32.ActiveCfg = Release|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.All|Win32.Build.0 = Release|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.All|x64.ActiveCfg = Release|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.Debug|Win32.ActiveCfg = Debug|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.Debug|x64.ActiveCfg = Debug|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.Release|Win32.ActiveCfg = Release|Win32 + {CC1DD008-9406-448d-A0AD-33C3186CFADB}.Release|x64.ActiveCfg = Release|Win32 {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32 {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.Build.0 = All|Win32 {DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|x64.ActiveCfg = All|Win32 @@ -2770,6 +2782,7 @@ Global {0DF3ABD0-DDC0-4265-B778-07C66780979B} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {B3F424EC-3D8F-417C-B244-3919D5E1A577} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {05C9FB27-480E-4D53-B3B7-6338E2526666} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} + {CC1DD008-9406-448d-A0AD-33C3186CFADB} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C} {30A5B29C-983E-4580-9FD0-D647CCDCC7EB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {B69247FA-ECD6-40ED-8E44-5CA6C3BAF9A4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} diff --git a/src/mod/endpoints/mod_skinny/mod_skinny.c b/src/mod/endpoints/mod_skinny/mod_skinny.c index 4e493b3a3b..df0aaddbf2 100644 --- a/src/mod/endpoints/mod_skinny/mod_skinny.c +++ b/src/mod/endpoints/mod_skinny/mod_skinny.c @@ -145,8 +145,10 @@ skinny_profile_t *skinny_find_profile(const char *profile_name) switch_status_t skinny_profile_find_listener_by_device_name(skinny_profile_t *profile, const char *device_name, listener_t **listener) { + listener_t *l; + switch_mutex_lock(profile->listener_mutex); - for (listener_t *l = profile->listeners; l; l = l->next) { + for (l = profile->listeners; l; l = l->next) { if (!strcmp(l->device_name, device_name)) { *listener = l; } @@ -158,8 +160,10 @@ switch_status_t skinny_profile_find_listener_by_device_name(skinny_profile_t *pr switch_status_t skinny_profile_find_listener_by_device_name_and_instance(skinny_profile_t *profile, const char *device_name, uint32_t device_instance, listener_t **listener) { + listener_t *l; + switch_mutex_lock(profile->listener_mutex); - for (listener_t *l = profile->listeners; l; l = l->next) { + for (l = profile->listeners; l; l = l->next) { if (!strcmp(l->device_name, device_name) && (l->device_instance == device_instance)) { *listener = l; } @@ -1084,9 +1088,7 @@ switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, swi switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event) { - struct private_object *tech_pvt = switch_core_session_get_private(session); char *body = switch_event_get_body(event); - switch_assert(tech_pvt != NULL); if (!body) { body = ""; diff --git a/src/mod/endpoints/mod_skinny/skinny_server.c b/src/mod/endpoints/mod_skinny/skinny_server.c index 73a4aab995..7c3c089e30 100644 --- a/src/mod/endpoints/mod_skinny/skinny_server.c +++ b/src/mod/endpoints/mod_skinny/skinny_server.c @@ -1324,6 +1324,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin struct button_template_helper helper = {0}; skinny_profile_t *profile; char *sql; + int i; switch_assert(listener->profile); switch_assert(listener->device_name); @@ -1367,7 +1368,7 @@ switch_status_t skinny_handle_button_template_request(listener_t *listener, skin } /* Fill remaining buttons with Undefined */ - for(int i = 0; i+1 < helper.max_position; i++) { + for(i = 0; i+1 < helper.max_position; i++) { if(message->data.button_template.btn[i].button_definition == SKINNY_BUTTON_UNKNOWN) { message->data.button_template.btn[i].instance_number = ++helper.count[SKINNY_BUTTON_UNDEFINED]; message->data.button_template.btn[i].button_definition = SKINNY_BUTTON_UNDEFINED; @@ -1546,7 +1547,11 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste tech_pvt->agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000, switch_rtp_ready(tech_pvt->rtp_session) ? "SUCCESS" : err); +#ifdef WIN32 + addr.s_addr = inet_addr((uint16_t) tech_pvt->local_sdp_audio_ip); +#else inet_aton(tech_pvt->local_sdp_audio_ip, &addr); +#endif send_start_media_transmission(listener, tech_pvt->call_id, /* uint32_t conference_id, */ tech_pvt->party_id, /* uint32_t pass_thru_party_id, */ diff --git a/src/mod/endpoints/mod_skinny/skinny_tables.h b/src/mod/endpoints/mod_skinny/skinny_tables.h index 5efd774648..d3b369bb14 100644 --- a/src/mod/endpoints/mod_skinny/skinny_tables.h +++ b/src/mod/endpoints/mod_skinny/skinny_tables.h @@ -44,8 +44,9 @@ struct skinny_table { const char *func(uint32_t id) \ { \ const char *str = DEFAULT_STR; \ + uint8_t x; \ \ - for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ + for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ if (TABLE[x].id == id) {\ str = TABLE[x].name;\ break;\ @@ -58,12 +59,13 @@ const char *func(uint32_t id) \ #define SKINNY_DECLARE_STR2ID(func, TABLE, DEFAULT_ID) \ uint32_t func(const char *str)\ {\ - uint32_t id = DEFAULT_ID;\ + uint32_t id = (uint32_t) DEFAULT_ID;\ \ if (*str > 47 && *str < 58) {\ id = atoi(str);\ } else {\ - for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1 && TABLE[x].name; x++) {\ + uint8_t x;\ + for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1 && TABLE[x].name; x++) {\ if (!strcasecmp(TABLE[x].name, str)) {\ id = TABLE[x].id;\ break;\ @@ -75,7 +77,8 @@ uint32_t func(const char *str)\ #define SKINNY_DECLARE_PUSH_MATCH(TABLE) \ switch_console_callback_match_t *my_matches = NULL;\ - for (uint8_t x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ + uint8_t x;\ + for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\ switch_console_push_match(&my_matches, TABLE[x].name);\ }\ if (my_matches) {\