提交 17176ff6 authored 作者: Giovanni Maruzzelli's avatar Giovanni Maruzzelli

skypiax: no more tcp ports in config, timing tweakings

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16724 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 f4d6fe83
...@@ -167,6 +167,7 @@ static struct { ...@@ -167,6 +167,7 @@ static struct {
private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
switch_mutex_t *mutex; switch_mutex_t *mutex;
private_t *sk_console; private_t *sk_console;
int start_port;
} globals; } globals;
switch_endpoint_interface_t *skypiax_endpoint_interface; switch_endpoint_interface_t *skypiax_endpoint_interface;
...@@ -1448,6 +1449,7 @@ static switch_status_t load_config(int reload_type) ...@@ -1448,6 +1449,7 @@ static switch_status_t load_config(int reload_type)
} }
} }
globals.start_port=32769;
if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) { if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
int i = 0; int i = 0;
...@@ -1716,6 +1718,8 @@ static switch_status_t load_config(int reload_type) ...@@ -1716,6 +1718,8 @@ static switch_status_t load_config(int reload_type)
switch_sleep(10000); switch_sleep(10000);
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET WINDOWSTATE HIDDEN"); skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET WINDOWSTATE HIDDEN");
switch_sleep(10000); switch_sleep(10000);
skypiax_signaling_write(&globals.SKYPIAX_INTERFACES[interface_id], "SET USERSTATUS ONLINE");
switch_sleep(10000);
} else { } else {
ERRORA 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", ("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",
...@@ -2831,6 +2835,14 @@ SWITCH_STANDARD_API(skypiax_chat_function) ...@@ -2831,6 +2835,14 @@ SWITCH_STANDARD_API(skypiax_chat_function)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
int next_port(void){
switch_mutex_lock(globals.mutex);
globals.start_port++;
if(globals.start_port == 65000)
globals.start_port=32769;
switch_mutex_unlock(globals.mutex);
return (globals.start_port - 1);
}
/* For Emacs: /* For Emacs:
......
...@@ -339,3 +339,4 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, int *which_port); ...@@ -339,3 +339,4 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, int *which_port);
int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_port); int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_port);
#endif //WIN32 #endif //WIN32
int incoming_chatmessage(private_t * tech_pvt, int which); int incoming_chatmessage(private_t * tech_pvt, int which);
int next_port(void);
...@@ -55,6 +55,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p ...@@ -55,6 +55,7 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
if (*which_port != 0) if (*which_port != 0)
start_port = *which_port; start_port = *which_port;
start_port=next_port();
my_addr.sin_port = htons(start_port); my_addr.sin_port = htons(start_port);
//fcntl(s, F_SETFL, O_NONBLOCK); //fcntl(s, F_SETFL, O_NONBLOCK);
//tech_pvt->tcp_cli_port = start_port; //tech_pvt->tcp_cli_port = start_port;
...@@ -501,8 +502,11 @@ int skypiax_signaling_read(private_t * tech_pvt) ...@@ -501,8 +502,11 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id);
} }
if (!strcasecmp(prop, "DURATION")) { /* each second, we sync ithe timers */ if (!strcasecmp(prop, "DURATION")) { /* each second, we sync ithe timers */
if(!((atoi(value) % 5))){
switch_core_timer_sync(&tech_pvt->timer_read); switch_core_timer_sync(&tech_pvt->timer_read);
switch_core_timer_sync(&tech_pvt->timer_write); switch_core_timer_sync(&tech_pvt->timer_write);
DEBUGA_SKYPE("Synching on skype_call: %s.\n", SKYPIAX_P_LOG, id);
}
} }
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
if (strcasecmp(id, tech_pvt->skype_call_id)) { if (strcasecmp(id, tech_pvt->skype_call_id)) {
...@@ -1134,10 +1138,12 @@ void *skypiax_do_tcp_cli_thread_func(void *obj) ...@@ -1134,10 +1138,12 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
#endif //0 #endif //0
#if 0
if(tech_pvt->begin_to_write==0){ if(tech_pvt->begin_to_write==0){
skypiax_sleep(1000); skypiax_sleep(1000);
continue; continue;
} }
#endif//0
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
switch_core_timer_next(&tech_pvt->timer_write); switch_core_timer_next(&tech_pvt->timer_write);
} }
...@@ -1364,6 +1370,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj) ...@@ -1364,6 +1370,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
if (!(running && tech_pvt->running)) if (!(running && tech_pvt->running))
break; break;
skypiax_sleep(2000);
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
...@@ -1382,10 +1389,6 @@ void *skypiax_do_tcp_srv_thread_func(void *obj) ...@@ -1382,10 +1389,6 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
to.tv_usec = 60000; //60 msec to.tv_usec = 60000; //60 msec
to.tv_sec = 0; to.tv_sec = 0;
if(tech_pvt->begin_to_read==0){
skypiax_sleep(1000);
continue;
}
rt = select(fdselect + 1, &fs, NULL, NULL, &to); rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (rt > 0) { if (rt > 0) {
...@@ -1394,6 +1397,12 @@ void *skypiax_do_tcp_srv_thread_func(void *obj) ...@@ -1394,6 +1397,12 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
} else { } else {
continue; continue;
} }
#if 1
if(tech_pvt->begin_to_read==0){
DEBUGA_SKYPE("len=%d, expected 640\n", SKYPIAX_P_LOG, len);
continue;
}
#endif //0
if (len == -1) { if (len == -1) {
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno)); DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
...@@ -1404,13 +1413,14 @@ void *skypiax_do_tcp_srv_thread_func(void *obj) ...@@ -1404,13 +1413,14 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
switch_buffer_write(tech_pvt->read_buffer, srv_in, len); switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
switch_mutex_unlock(tech_pvt->mutex_audio_srv); switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} else if (len == 0) { } else if (len == 0) {
DEBUGA_SKYPE("CLOSING, len=%d, expected 640\n", SKYPIAX_P_LOG, len); DEBUGA_SKYPE("CLOSED, len=%d, expected 640\n", SKYPIAX_P_LOG, len);
break; break;
} else { } else {
DEBUGA_SKYPE("len=%d, expected 640\n", SKYPIAX_P_LOG, len); DEBUGA_SKYPE("len=%d, expected 640\n", SKYPIAX_P_LOG, len);
} }
} else if(rt==0){ } else if(rt==0){
DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
continue; continue;
} else { } else {
DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt); DEBUGA_SKYPE("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
...@@ -1534,11 +1544,22 @@ void *skypiax_do_tcp_cli_thread_func(void *obj) ...@@ -1534,11 +1544,22 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
fdselect = fd; fdselect = fd;
FD_SET(fdselect, &fs); FD_SET(fdselect, &fs);
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next && tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
switch_core_timer_next(&tech_pvt->timer_write);
}
#if 1
if(tech_pvt->begin_to_write==0){ if(tech_pvt->begin_to_write==0){
skypiax_sleep(1000); memset(cli_out, 255, sizeof(cli_out));
continue; bytes_to_write = 320;
len = send(fd, (char *)cli_out, bytes_to_write, 0);
if (len == -1) {
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPIAX_P_LOG, len, strerror(errno));
break;
}
continue;
} }
#endif//0
//rt = select(fdselect + 1, NULL, &fs, NULL, &to); //rt = select(fdselect + 1, NULL, &fs, NULL, &to);
//if(rt==-1) //if(rt==-1)
...@@ -1548,9 +1569,9 @@ void *skypiax_do_tcp_cli_thread_func(void *obj) ...@@ -1548,9 +1569,9 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
if (rt > 0) { if (rt > 0) {
//DEBUGA_SKYPE("before!\n", SKYPIAX_P_LOG); //DEBUGA_SKYPE("before!\n", SKYPIAX_P_LOG);
if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next && tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { //if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next && tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
switch_core_timer_next(&tech_pvt->timer_write); //switch_core_timer_next(&tech_pvt->timer_write);
} //}
//DEBUGA_SKYPE("after!\n", SKYPIAX_P_LOG); //DEBUGA_SKYPE("after!\n", SKYPIAX_P_LOG);
bytes_to_write=0; bytes_to_write=0;
waitin=0; waitin=0;
...@@ -1581,6 +1602,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj) ...@@ -1581,6 +1602,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
} }
} }
} else if(rt==0){ } else if(rt==0){
DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
continue; continue;
} else { } else {
DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt); DEBUGA_SKYPE("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论