diff --git a/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c b/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c index 2ebdafe9d2..4fa0a1c0fd 100644 --- a/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c +++ b/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c @@ -144,7 +144,7 @@ struct ast_cli_entry myclis[] = { AST_CLI_DEFINE(skypiax_console_skype, "Sends a Skype command"), AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, "imports entries from cellphone"), AST_CLI_DEFINE(skypiax_console_skypiax, "all things skypiax"), - #endif +#endif }; #else struct ast_cli_entry myclis[] = { @@ -313,15 +313,15 @@ struct ast_channel *skypiax_request(const char *type, int format, void *data, in return NULL; } -char interface[256]; -int i; -memset(interface, '\0', sizeof(interface)); + char interface[256]; + int i; + memset(interface, '\0', sizeof(interface)); -for (i=0; ivalue, &skypiax_default.capture_boost)) M_UINT("skypiax_dir_entry_extension_prefix", skypiax_default.skypiax_dir_entry_extension_prefix) - M_END(; - ); + M_END(;); } } @@ -1161,8 +1160,7 @@ struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg, int is_first M_STR("skype_user", tmp->skype_user) M_UINT("skypiax_dir_entry_extension_prefix", tmp->skypiax_dir_entry_extension_prefix) - M_END(; - ); + M_END(;); } if (debug_all) { @@ -1861,7 +1859,9 @@ int new_inbound_channel(private_t * p) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { switch_core_session_add_stream(session, NULL); channel = switch_core_session_get_channel(session); skypiax_tech_init(tech_pvt, session); @@ -1889,6 +1889,7 @@ int new_inbound_channel(private_t * p) #endif return 0; } + int remote_party_is_ringing(private_t * p) { if (p->owner) { @@ -1897,6 +1898,7 @@ int remote_party_is_ringing(private_t * p) return 0; } + int remote_party_is_early_media(private_t * p) { if (p->owner) { @@ -1906,7 +1908,6 @@ int remote_party_is_early_media(private_t * p) return 0; } - int outbound_channel_answered(private_t * p) { diff --git a/src/mod/endpoints/mod_skypiax/mod_skypiax.c b/src/mod/endpoints/mod_skypiax/mod_skypiax.c index 6aa1fd8a7b..3b5cb9bad9 100644 --- a/src/mod/endpoints/mod_skypiax/mod_skypiax.c +++ b/src/mod/endpoints/mod_skypiax/mod_skypiax.c @@ -506,7 +506,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * sess switch_memory_pool_t ** pool, switch_originate_flag_t flags) { - if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) { + if ((*new_session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) { private_t *tech_pvt; switch_channel_t *channel; switch_caller_profile_t *caller_profile; @@ -940,29 +942,43 @@ static switch_status_t load_config(void) skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]); - NOTICA("WAITING roughly 10/15 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d. NB: on XP will wait for much much more! (on Vista and Linux is OK)\n", SKYPIAX_P_LOG, interface_id); + NOTICA + ("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n", + SKYPIAX_P_LOG, interface_id); i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) { // 10 seconds? thanks Jeff Lenk + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 200) { // 10 seconds! thanks Jeff Lenk switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) { - NOTICA("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting roughly 60/90 seconds for CURRENTUSERHANDLE==%s. NB: on XP will wait for much much more! (on Vista and Linux is OK)\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + NOTICA + ("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n", + SKYPIAX_P_LOG, interface_id, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); } else { - ERRORA("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n", SKYPIAX_P_LOG, interface_id); + ERRORA + ("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypiax exiting\n", + SKYPIAX_P_LOG, interface_id); running = 0; return SWITCH_STATUS_FALSE; } i = 0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds? thanks Jeff Lenk + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds! thanks Jeff Lenk switch_sleep(50000); i++; } if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) { - WARNINGA("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + WARNINGA + ("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n", + SKYPIAX_P_LOG, interface_id, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); } else { - ERRORA("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n", SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, globals.SKYPIAX_INTERFACES[interface_id].skype_user); + ERRORA + ("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypiax exiting now\n", + SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, + interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user, + globals.SKYPIAX_INTERFACES[interface_id].skype_user); running = 0; return SWITCH_STATUS_FALSE; } @@ -1056,7 +1072,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) DEBUGA_SKYPE ("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError()); - globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread=NULL; + globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL; } #else XEvent e; @@ -1075,9 +1091,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) XSync(tech_pvt->SkypiaxHandles.disp, False); #endif } - while (x) {//FIXME 2 seconds? + while (x) { //FIXME 2 seconds? x--; - switch_yield(20000); + switch_yield(20000); } if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) { switch_thread_join(&status, @@ -1164,7 +1180,9 @@ int new_inbound_channel(private_t * tech_pvt) switch_core_session_t *session = NULL; switch_channel_t *channel = NULL; - if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) { switch_core_session_add_stream(session, NULL); channel = switch_core_session_get_channel(session); skypiax_tech_init(tech_pvt, session); @@ -1221,7 +1239,6 @@ int remote_party_is_ringing(private_t * tech_pvt) return 0; } - int remote_party_is_early_media(private_t * tech_pvt) { switch_core_session_t *session = NULL; diff --git a/src/mod/endpoints/mod_skypiax/skypiax_protocol.c b/src/mod/endpoints/mod_skypiax/skypiax_protocol.c index f72a3c5d10..0300139c2e 100644 --- a/src/mod/endpoints/mod_skypiax/skypiax_protocol.c +++ b/src/mod/endpoints/mod_skypiax/skypiax_protocol.c @@ -273,17 +273,17 @@ int skypiax_signaling_read(private_t * tech_pvt) char msg_to_skype[1024]; tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", - SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - start_audio_threads(tech_pvt); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, - tech_pvt->tcp_srv_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); + NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, + id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + start_audio_threads(tech_pvt); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); - remote_party_is_early_media(tech_pvt); + remote_party_is_early_media(tech_pvt); } else if (!strcasecmp(value, "MISSED")) { DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); } else if (!strcasecmp(value, "FINISHED")) { @@ -355,17 +355,17 @@ int skypiax_signaling_read(private_t * tech_pvt) || !strcasecmp(tech_pvt->skype_call_id, id)) { strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA){ - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - tech_pvt->interface_state = SKYPIAX_STATE_UP; - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - start_audio_threads(tech_pvt); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, - tech_pvt->tcp_srv_port); - skypiax_signaling_write(tech_pvt, msg_to_skype); - } + if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + tech_pvt->interface_state = SKYPIAX_STATE_UP; + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + start_audio_threads(tech_pvt); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_signaling_write(tech_pvt, msg_to_skype); + } tech_pvt->skype_callflow = SKYPIAX_STATE_UP; if (!strlen(tech_pvt->session_uuid_str)) { DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); @@ -456,7 +456,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj) break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA + || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; @@ -607,7 +607,8 @@ void *skypiax_do_tcp_cli_thread_func(void *obj) if (!running) break; while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA + && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { unsigned int fdselect; int rt; @@ -921,8 +922,8 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, lReturnCode = 0; fIssueDefProc = 0; tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA); - if(!running) - return lReturnCode; + if (!running) + return lReturnCode; switch (uiMessage) { case WM_CREATE: tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; @@ -1141,7 +1142,7 @@ int X11_errors_handler(Display * dpy, XErrorEvent * err) xerror = err->error_code; ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); - running=0; + running = 0; return 0; /* ignore the error */ } @@ -1248,7 +1249,7 @@ int skypiax_present(struct SkypiaxHandles *SkypiaxHandles) if (status != Success || format_ret != 32 || nitems_ret != 1) { SkypiaxHandles->skype_win = (Window) - 1; DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); - running =0; + running = 0; SkypiaxHandles->api_connected = 0; return 0; }