mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-24 19:52:35 +00:00
skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14375 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
44875f02c4
commit
d6f9544be3
@ -44,53 +44,43 @@
|
|||||||
|
|
||||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||||
#else
|
#else /* */
|
||||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||||
#endif
|
#endif /* */
|
||||||
|
struct timezone {
|
||||||
struct timezone
|
|
||||||
{
|
|
||||||
int tz_minuteswest; /* minutes W of Greenwich */
|
int tz_minuteswest; /* minutes W of Greenwich */
|
||||||
int tz_dsttime; /* type of dst correction */
|
int tz_dsttime; /* type of dst correction */
|
||||||
};
|
};
|
||||||
|
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
{
|
||||||
{
|
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
unsigned __int64 tmpres = 0;
|
unsigned __int64 tmpres = 0;
|
||||||
static int tzflag;
|
static int tzflag;
|
||||||
|
if (NULL != tv) {
|
||||||
if (NULL != tv)
|
|
||||||
{
|
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
|
|
||||||
tmpres |= ft.dwHighDateTime;
|
tmpres |= ft.dwHighDateTime;
|
||||||
tmpres <<= 32;
|
tmpres <<= 32;
|
||||||
tmpres |= ft.dwLowDateTime;
|
tmpres |= ft.dwLowDateTime;
|
||||||
|
|
||||||
/*converting file time to unix epoch*/
|
/*converting file time to unix epoch */
|
||||||
tmpres /= 10; /*convert into microseconds*/
|
tmpres /= 10; /*convert into microseconds */
|
||||||
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
||||||
tv->tv_sec = (long)(tmpres / 1000000UL);
|
tv->tv_sec = (long) (tmpres / 1000000UL);
|
||||||
tv->tv_usec = (long)(tmpres % 1000000UL);
|
tv->tv_usec = (long) (tmpres % 1000000UL);
|
||||||
}
|
}
|
||||||
|
if (NULL != tz) {
|
||||||
if (NULL != tz)
|
if (!tzflag) {
|
||||||
{
|
|
||||||
if (!tzflag)
|
|
||||||
{
|
|
||||||
_tzset();
|
_tzset();
|
||||||
tzflag++;
|
tzflag++;
|
||||||
}
|
}
|
||||||
tz->tz_minuteswest = _timezone / 60;
|
tz->tz_minuteswest = _timezone / 60;
|
||||||
tz->tz_dsttime = _daylight;
|
tz->tz_dsttime = _daylight;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************/
|
/***************/
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
|
||||||
SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL);
|
SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL);
|
||||||
@ -140,8 +130,8 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string,
|
|||||||
globals.codec_rates_string);
|
globals.codec_rates_string);
|
||||||
|
|
||||||
/* BEGIN: Changes here */
|
/* BEGIN: Changes here */
|
||||||
static switch_status_t interface_exists(char* skype_user);
|
static switch_status_t interface_exists(char *skype_user);
|
||||||
static switch_status_t remove_interface(char* skype_user);
|
static switch_status_t remove_interface(char *skype_user);
|
||||||
/* END: Changes here */
|
/* END: Changes here */
|
||||||
|
|
||||||
static switch_status_t channel_on_init(switch_core_session_t * session);
|
static switch_status_t channel_on_init(switch_core_session_t * session);
|
||||||
@ -221,11 +211,12 @@ void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* BEGIN: Changes here */
|
/* BEGIN: Changes here */
|
||||||
static switch_status_t interface_exists(char* skype_user) {
|
static switch_status_t interface_exists(char *skype_user)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
|
for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
|
||||||
if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
|
if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
|
||||||
if(strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, skype_user) == 0) {
|
if (strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, skype_user) == 0) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +224,8 @@ static switch_status_t interface_exists(char* skype_user) {
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status_t remove_interface(char* skype_user) {
|
static switch_status_t remove_interface(char *skype_user)
|
||||||
|
{
|
||||||
int x = 100;
|
int x = 100;
|
||||||
unsigned int howmany = 8;
|
unsigned int howmany = 8;
|
||||||
int interface_id = -1;
|
int interface_id = -1;
|
||||||
@ -243,14 +235,15 @@ static switch_status_t remove_interface(char* skype_user) {
|
|||||||
running = 0;
|
running = 0;
|
||||||
|
|
||||||
for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
|
for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
|
||||||
if(strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user) == 0) {
|
if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user) == 0) {
|
||||||
tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
|
tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tech_pvt) {
|
if (!tech_pvt) {
|
||||||
DEBUGA_SKYPE("interface for skype user '%s' does not exist\n", SKYPIAX_P_LOG, skype_user);
|
DEBUGA_SKYPE("interface for skype user '%s' does not exist\n", SKYPIAX_P_LOG,
|
||||||
|
skype_user);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,13 +263,15 @@ static switch_status_t remove_interface(char* skype_user) {
|
|||||||
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
|
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypiax_api_thread_func die
|
if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypiax_api_thread_func die
|
||||||
DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n",
|
DEBUGA_SKYPE
|
||||||
|
("got FALSE here, thread probably was already dead. GetLastError returned: %d\n",
|
||||||
SKYPIAX_P_LOG, GetLastError());
|
SKYPIAX_P_LOG, GetLastError());
|
||||||
globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
|
globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
XEvent e;
|
XEvent e;
|
||||||
Atom atom1 = XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
Atom atom1 =
|
||||||
|
XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
||||||
memset(&e, 0, sizeof(e));
|
memset(&e, 0, sizeof(e));
|
||||||
e.xclient.type = ClientMessage;
|
e.xclient.type = ClientMessage;
|
||||||
e.xclient.message_type = atom1; /* leading message */
|
e.xclient.message_type = atom1; /* leading message */
|
||||||
@ -295,19 +290,23 @@ static switch_status_t remove_interface(char* skype_user) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
|
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
|
||||||
switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
|
switch_thread_join(&status,
|
||||||
|
globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
|
if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
|
||||||
switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
|
switch_thread_join(&status,
|
||||||
|
globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&globals.SKYPIAX_INTERFACES[interface_id], '\0',sizeof(private_t));
|
memset(&globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
|
||||||
DEBUGA_SKYPE("interface for skype user '%s' deleted successfully\n", SKYPIAX_P_LOG, skype_user);
|
DEBUGA_SKYPE("interface for skype user '%s' deleted successfully\n", SKYPIAX_P_LOG,
|
||||||
|
skype_user);
|
||||||
end:
|
end:
|
||||||
running = 1;
|
running = 1;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* END: Changes here */
|
/* END: Changes here */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -983,8 +982,8 @@ static switch_status_t load_config(int reload_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* BEGIN: Changes here */
|
/* BEGIN: Changes here */
|
||||||
if(reload_type == SOFT_RELOAD) {
|
if (reload_type == SOFT_RELOAD) {
|
||||||
if(interface_exists(skype_user) == SWITCH_STATUS_SUCCESS) {
|
if (interface_exists(skype_user) == SWITCH_STATUS_SUCCESS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1622,18 +1621,18 @@ SWITCH_STANDARD_API(sk_function)
|
|||||||
|
|
||||||
/* BEGIN: Changes heres */
|
/* BEGIN: Changes heres */
|
||||||
} else if (!strcasecmp(argv[0], "reload")) {
|
} else if (!strcasecmp(argv[0], "reload")) {
|
||||||
if(load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
|
if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
|
||||||
stream->write_function(stream, "sk reload failed\n");
|
stream->write_function(stream, "sk reload failed\n");
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "sk reload success\n");
|
stream->write_function(stream, "sk reload success\n");
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(argv[0], "remove")) {
|
} else if (!strcasecmp(argv[0], "remove")) {
|
||||||
if(argc == 2) {
|
if (argc == 2) {
|
||||||
if(remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
|
if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
|
||||||
if(interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
|
if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
|
||||||
stream->write_function(stream, "sk remove '%s' failed\n", argv[1]);
|
stream->write_function(stream, "sk remove '%s' failed\n", argv[1]);
|
||||||
} else {
|
} else {
|
||||||
stream->write_function(stream, "sk remove '%s' success\n",argv[1]);
|
stream->write_function(stream, "sk remove '%s' success\n", argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#include <switch_version.h>
|
#include <switch_version.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
@ -252,8 +252,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
|||||||
char msg_to_skype[1024];
|
char msg_to_skype[1024];
|
||||||
tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
|
||||||
tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
|
tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
|
||||||
DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
|
DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
|
||||||
id);
|
SKYPIAX_P_LOG, id);
|
||||||
start_audio_threads(tech_pvt);
|
start_audio_threads(tech_pvt);
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
||||||
@ -733,12 +733,12 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
int counter;
|
int counter;
|
||||||
|
|
||||||
/* until we drained the pipe to empty */
|
/* until we drained the pipe to empty */
|
||||||
for(counter = 0; counter < 10; counter++){
|
for (counter = 0; counter < 10; counter++) {
|
||||||
/* read from the pipe the audio frame we are supposed to send out */
|
/* read from the pipe the audio frame we are supposed to send out */
|
||||||
got =
|
got =
|
||||||
skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
|
skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
|
||||||
SAMPLES_PER_FRAME * sizeof(short));
|
SAMPLES_PER_FRAME * sizeof(short));
|
||||||
if(got == -1)
|
if (got == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (got != SAMPLES_PER_FRAME * sizeof(short)) {
|
if (got != SAMPLES_PER_FRAME * sizeof(short)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user