[Freeswitch-branches] [commit] r10474 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Thu Nov 20 04:17:02 PST 2008
Author: gmaruzz
Date: Thu Nov 20 07:17:01 2008
New Revision: 10474
Log:
skypiax: cosmetics
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Nov 20 07:17:01 2008
@@ -57,27 +57,27 @@
/*********************************/
-#define AST_CAUSE_NORMAL 1
+#define SKYPIAX_CAUSE_NORMAL 1
/*********************************/
-#define AST_FRAME_DTMF 1
+#define SKYPIAX_FRAME_DTMF 1
/*********************************/
-#define AST_CONTROL_RINGING 1
-#define AST_CONTROL_ANSWER 2
+#define SKYPIAX_CONTROL_RINGING 1
+#define SKYPIAX_CONTROL_ANSWER 2
/*********************************/
-#define AST_STATE_DOWN 1
-#define AST_STATE_RING 2
-#define AST_STATE_DIALING 3
-#define AST_STATE_BUSY 4
-#define AST_STATE_UP 5
-#define AST_STATE_RINGING 6
-#define AST_STATE_PRERING 7
+#define SKYPIAX_STATE_DOWN 1
+#define SKYPIAX_STATE_RING 2
+#define SKYPIAX_STATE_DIALING 3
+#define SKYPIAX_STATE_BUSY 4
+#define SKYPIAX_STATE_UP 5
+#define SKYPIAX_STATE_RINGING 6
+#define SKYPIAX_STATE_PRERING 7
/*********************************/
/* call flow from the device */
-#define CALLFLOW_CALL_IDLE AST_STATE_DOWN
-#define CALLFLOW_INCOMING_RING AST_STATE_RING
-#define CALLFLOW_CALL_DIALING AST_STATE_DIALING
-#define CALLFLOW_CALL_LINEBUSY AST_STATE_BUSY
+#define CALLFLOW_CALL_IDLE SKYPIAX_STATE_DOWN
+#define CALLFLOW_INCOMING_RING SKYPIAX_STATE_RING
+#define CALLFLOW_CALL_DIALING SKYPIAX_STATE_DIALING
+#define CALLFLOW_CALL_LINEBUSY SKYPIAX_STATE_BUSY
#define CALLFLOW_CALL_ACTIVE 300
#define CALLFLOW_INCOMING_HANGUP 100
#define CALLFLOW_CALL_RELEASED 101
@@ -98,7 +98,7 @@
#define CALLFLOW_STATUS_UNPLACED 116
#define CALLFLOW_STATUS_ROUTING 117
#define CALLFLOW_STATUS_EARLYMEDIA 118
-#define AST_STATE_HANGUP_REQUESTED 200
+#define SKYPIAX_STATE_HANGUP_REQUESTED 200
//FIXME CALLFLOW_INCOMING_CALLID to be removed
#define CALLFLOW_INCOMING_CALLID 1019
@@ -161,8 +161,8 @@
switch_mutex_t *mutex;
} globals;
-struct skypiax_config {
- char span_id[80];
+struct skypiax_interface {
+ char interface_id[80];
char name[80];
char dialplan[80];
char context[80];
@@ -212,9 +212,9 @@
void *tech_pvt;
};
-typedef struct skypiax_config skypiax_config_t;
+typedef struct skypiax_interface skypiax_interface_t;
-static skypiax_config_t SKYPIAX_CONFIGS[SKYPIAX_MAX_INTERFACES];
+static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
struct private_object {
@@ -227,7 +227,7 @@
switch_caller_profile_t *caller_profile;
switch_mutex_t *mutex;
switch_mutex_t *flag_mutex;
- skypiax_config_t *p;
+ skypiax_interface_t *p;
//switch_thread_cond_t *cond;
};
@@ -394,7 +394,7 @@
#define GG 160
static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
{
- struct skypiax_config *p = obj;
+ struct skypiax_interface *p = obj;
short in[GG];
short out[GG / 2];
int s, fd, len, sent;
@@ -484,7 +484,7 @@
static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
//void *skypiax_do_tcp_cli_thread(void *data)
{
- struct skypiax_config *p = obj;
+ struct skypiax_interface *p = obj;
int s, fd, len;
short in[NN / 2];
short out[NN];
@@ -526,7 +526,7 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
ERRORA("ACCEPTED\n", SKYPIAX_P_LOG);
- //while (1 && p->owner && p->owner->_state == AST_STATE_UP) FIXME FIXME FIXME
+ //while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
while (1) {
got = read(p->audioskypepipe[0], in, (NN / 2) * sizeof(short));
@@ -565,7 +565,7 @@
}
-int skypiax_skypeaudio_init(struct skypiax_config *p)
+int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
int c;
/* build the pipe that will be polled on by pbx */
@@ -622,7 +622,7 @@
}
static switch_status_t skypiax_skypeaudio_read(private_t *tech_pvt)
{
- struct skypiax_config *p;
+ struct skypiax_interface *p;
short buf[640];
int samples;
@@ -653,21 +653,21 @@
#ifdef NOTDEF
//cicopet
-struct ast_frame *skypiax_skypeaudio_read(struct skypiax_config *p)
+struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p)
{
static struct ast_frame f;
- static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
+ static short __buf[SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2];
short *buf;
int samples;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
- memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2));
+ memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2));
- buf = __buf + AST_FRIENDLY_OFFSET / 2;
+ buf = __buf + SKYPIAX_FRIENDLY_OFFSET / 2;
- f.frametype = AST_FRAME_NULL;
+ f.frametype = SKYPIAX_FRAME_NULL;
f.subclass = 0;
f.samples = 0;
f.datalen = 0;
@@ -686,12 +686,12 @@
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
/* A real frame */
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
+ f.frametype = SKYPIAX_FRAME_VOICE;
+ f.subclass = SKYPIAX_FORMAT_SLINEAR;
f.samples = SKYPIAX_FRAME_SIZE;
f.datalen = SKYPIAX_FRAME_SIZE * 2;
f.data = buf;
- f.offset = AST_FRIENDLY_OFFSET;
+ f.offset = SKYPIAX_FRIENDLY_OFFSET;
f.src = skypiax_type;
f.mallocd = 0;
}
@@ -704,9 +704,9 @@
#endif //NOTDEF
#endif /* SKYPE_AUDIO */
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_config_t *p)
+static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p)
{
- //struct skypiax_config *p = NULL;
+ //struct skypiax_interface *p = NULL;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
tech_pvt->read_frame.data = tech_pvt->databuf;
@@ -888,12 +888,12 @@
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
/* A real frame */
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
+ f.frametype = SKYPIAX_FRAME_VOICE;
+ f.subclass = SKYPIAX_FORMAT_SLINEAR;
f.samples = SKYPIAX_FRAME_SIZE;
f.datalen = SKYPIAX_FRAME_SIZE * 2;
f.data = buf;
- f.offset = AST_FRIENDLY_OFFSET;
+ f.offset = SKYPIAX_FRIENDLY_OFFSET;
f.src = skypiax_type;
f.mallocd = 0;
}
@@ -941,7 +941,7 @@
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
int sent;
- struct skypiax_config *p=NULL;
+ struct skypiax_interface *p=NULL;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
@@ -976,7 +976,7 @@
{
private_t *tech_pvt;
switch_channel_t *channel = NULL;
- struct skypiax_config *p;
+ struct skypiax_interface *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -996,7 +996,7 @@
{
switch_channel_t *channel;
private_t *tech_pvt;
- struct skypiax_config *p;
+ struct skypiax_interface *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -1038,7 +1038,7 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = SKYPIAX_CONFIGS[2]; //FIXME
+ tech_pvt->p = SKYPIAX_INTERFACES[2]; //FIXME
channel = switch_core_session_get_channel(*new_session);
tech_init(tech_pvt, *new_session, NULL);
} else {
@@ -1121,7 +1121,7 @@
int X11_errors_handler(Display * dpy, XErrorEvent * err)
{
(void) dpy;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
xerror = err->error_code;
DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror);
@@ -1147,7 +1147,7 @@
Window w_P;
Display *disp;
Window handle_P;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
w_P = AsteriskHandlesAst->skype_win;
disp = AsteriskHandlesAst->disp;
@@ -1199,7 +1199,7 @@
unsigned long bytes_after_ret;
unsigned char *prop;
int status;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
X11_errors_trap();
//XLockDisplay(disp);
@@ -1228,7 +1228,7 @@
int *dispptr;
int disp;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
dispptr = data;
disp = *dispptr;
@@ -1247,7 +1247,7 @@
static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
{
- struct skypiax_config *p;
+ struct skypiax_interface *p;
struct AsteriskHandles *AsteriskHandlesAst;
char buf[SKYPE_X11_BUF_SIZE];
Display *disp = NULL;
@@ -1317,7 +1317,7 @@
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1328,7 +1328,7 @@
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1380,11 +1380,11 @@
("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
return NULL;
}
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
//pthread_cleanup_pop(1);
//DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
@@ -1399,7 +1399,7 @@
#if 1
#define WANT_SKYPE_X11
-int skypiax_skype_write(struct skypiax_config *p, char *msg_to_skype)
+int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
{
#ifdef __CYGWIN__
static char acInputRow[1024];
@@ -1424,7 +1424,7 @@
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
p->skype = 0;
- p->skype_thread = AST_PTHREADT_NULL;
+ p->skype_thread = SKYPIAX_PTHREADT_NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1447,7 +1447,7 @@
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1465,7 +1465,7 @@
#endif //0
-int skypiax_skype_read(struct skypiax_config *p)
+int skypiax_skype_read(struct skypiax_interface *p)
{
char read_from_pipe[4096];
@@ -1528,16 +1528,16 @@
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
}
@@ -1577,17 +1577,17 @@
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner){
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
//FIXME }
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
}
if (!strcasecmp(messaggio, "CALL")) {
@@ -1624,13 +1624,13 @@
if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
id);
- if (p->interface_state == AST_STATE_DOWN)
- p->interface_state = AST_STATE_PRERING;
+ if (p->interface_state == SKYPIAX_STATE_DOWN)
+ p->interface_state = SKYPIAX_STATE_PRERING;
}
if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
- if (p->interface_state == AST_STATE_DOWN)
- p->interface_state = AST_STATE_PRERING;
+ if (p->interface_state == SKYPIAX_STATE_DOWN)
+ p->interface_state = SKYPIAX_STATE_PRERING;
}
if (!strcasecmp(prop, "DTMF")) {
@@ -1638,7 +1638,7 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- //FIXME struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+ //FIXME struct ast_frame f2 = { SKYPIAX_FRAME_DTMF, value[0], };
DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
tech_pvt = p->tech_pvt;
@@ -1683,14 +1683,14 @@
if (!strcasecmp(value, "RINGING")) {
char msg_to_skype[1024];
- if (p->interface_state != AST_STATE_DIALING) {
+ if (p->interface_state != SKYPIAX_STATE_DIALING) {
/* we are not calling out */
//FIXME if (!p->owner)
if (1) {
/* we are not inside an active call */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = AST_STATE_RING;
+ p->interface_state = SKYPIAX_STATE_RING;
/* no owner, no active call, let's answer */
skypiax_skype_write(p, "SET AGC OFF");
usleep(10000);
@@ -1721,16 +1721,16 @@
} else {
/* we are calling out */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = AST_STATE_RINGING;
- //FIXME ast_queue_control(p->owner, AST_CONTROL_RINGING);
+ p->interface_state = SKYPIAX_STATE_RINGING;
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
SKYPIAX_P_LOG, id);
}
} else if (!strcasecmp(value, "EARLYMEDIA")) {
p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
- p->interface_state = AST_STATE_DIALING;
- //FIXME ast_queue_control(p->owner, AST_CONTROL_RINGING);
+ p->interface_state = SKYPIAX_STATE_DIALING;
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "MISSED")) {
@@ -1743,16 +1743,16 @@
DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
} else if (!strcasecmp(value, "CANCELLED")) {
@@ -1763,16 +1763,16 @@
SKYPIAX_P_LOG, id);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
} else if (!strcasecmp(value, "FAILED")) {
p->skype_callflow = CALLFLOW_STATUS_FAILED;
@@ -1782,12 +1782,12 @@
SKYPIAX_P_LOG, id);
p->skype_call_id[0] = '\0';
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
if (!strcasecmp(id, p->skype_call_id)) {
@@ -1798,13 +1798,13 @@
("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
SKYPIAX_P_LOG, id);
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
p->skype_call_id[0] = '\0';
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
/* we're here because were us that refused an incoming call */
@@ -1813,26 +1813,26 @@
}
} else if (!strcasecmp(value, "ROUTING")) {
p->skype_callflow = CALLFLOW_STATUS_ROUTING;
- p->interface_state = AST_STATE_DIALING;
+ p->interface_state = SKYPIAX_STATE_DIALING;
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "UNPLACED")) {
p->skype_callflow = CALLFLOW_STATUS_UNPLACED;
- p->interface_state = AST_STATE_DIALING;
+ p->interface_state = SKYPIAX_STATE_DIALING;
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "INPROGRESS")) {
p->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- p->interface_state = AST_STATE_UP;
+ p->interface_state = SKYPIAX_STATE_UP;
if (option_debug > 1)
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
//FIXME if (p->owner) {
- //FIXME ast_queue_control(p->owner, AST_CONTROL_ANSWER);
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER);
//FIXME }
if (option_debug > 1)
- DEBUGA_SKYPE("skype_call: %s AST_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
+ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
id);
//FIXME if (p->owner)
@@ -1875,7 +1875,7 @@
usleep(100000);
}
- p->skype_callflow = AST_STATE_UP;
+ p->skype_callflow = SKYPIAX_STATE_UP;
/**************************/
@@ -2010,7 +2010,7 @@
return 0;
}
-int skypiax_skype_call(struct skypiax_config *p, char *idest, int timeout, switch_core_session_t *session)
+int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session)
{
char rdest[80];
@@ -2050,9 +2050,9 @@
//p->skype_call_ongoing = 1;
//if (p->owner) {
- //ast_setstate(p->owner, AST_STATE_RINGING);
+ //ast_setstate(p->owner, SKYPIAX_STATE_RINGING);
//}
- //FIXME ast_queue_control(p->owner, AST_CONTROL_RINGING);
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
return 0;
}
@@ -2067,7 +2067,7 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = &SKYPIAX_CONFIGS[2]; //FIXME
+ tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME
channel = switch_core_session_get_channel(*new_session);
tech_init(tech_pvt, *new_session, NULL);
} else {
@@ -2111,7 +2111,7 @@
static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t *thread, void *obj)
//void *skypiax_do_controldev_thread(void *data)
{
- struct skypiax_config *p = obj;
+ struct skypiax_interface *p = obj;
int res;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -2128,7 +2128,7 @@
DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
if (p->owner) {
pthread_testcancel();
- ast_queue_control(p->owner, AST_CONTROL_HANGUP);
+ ast_queue_control(p->owner, SKYPIAX_CONTROL_HANGUP);
}
}
#endif
@@ -2147,21 +2147,21 @@
static switch_status_t load_config(void)
{
char *cf = "skypiax.conf";
- switch_xml_t cfg, xml, settings, param, spans, myspan;
+ switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
- memset(&globals, 0, sizeof(globals));
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
- if ((settings = switch_xml_child(cfg, "settings"))) {
- for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ if ((global_settings = switch_xml_child(cfg, "global_settings"))) {
+ for (param = switch_xml_child(global_settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "debug")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
globals.debug = atoi(val);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
} else if (!strcasecmp(var, "hold-music")) {
@@ -2194,12 +2194,12 @@
}
}
- if ((spans = switch_xml_child(cfg, "analog_spans"))) {
+ if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
int i=0;
- for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
- char *id = (char *) switch_xml_attr(myspan, "id");
- char *name = (char *) switch_xml_attr(myspan, "name");
+ for (myinterface = switch_xml_child(interfaces, "interface"); myinterface; myinterface = myinterface->next) {
+ char *id = (char *) switch_xml_attr(myinterface, "id");
+ char *name = (char *) switch_xml_attr(myinterface, "name");
char *context = "default";
char *dialplan = "XML";
char *tonegroup = NULL;
@@ -2212,9 +2212,9 @@
char *enable_callerid = "true";
char *X11_display = NULL;
- uint32_t span_id = 0, to = 0, max = 0;
+ uint32_t interface_id = 0, to = 0, max = 0;
- for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
+ for (param = switch_xml_child(myinterface, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -2245,25 +2245,25 @@
}
if (!X11_display) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing REQUIRED param 'X11_display'\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'X11_display'\n");
continue;
}
if (!id) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing REQUIRED param 'id'\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'id'\n");
continue;
}
if (switch_is_number(id)) {
- span_id = atoi(id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d\n", span_id);
+ interface_id = atoi(id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d\n", interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span param 'id' MUST be a number, now id='%s'\n", id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface param 'id' MUST be a number, now id='%s'\n", id);
continue;
}
if (!name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "span missing param 'name', not nice, but works\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "interface missing param 'name', not nice, but works\n");
}
if (!tonegroup) {
@@ -2281,25 +2281,25 @@
if (name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
}
- if(span_id && span_id < SKYPIAX_MAX_INTERFACES ) {
- struct skypiax_config newconf;
+ if(interface_id && interface_id < SKYPIAX_MAX_INTERFACES ) {
+ struct skypiax_interface newconf;
memset(&newconf, '\0', sizeof(newconf));
- SKYPIAX_CONFIGS[span_id]=newconf;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING span_id=%d\n", span_id);
- switch_set_string(SKYPIAX_CONFIGS[span_id].span_id, id);
+ SKYPIAX_INTERFACES[interface_id]=newconf;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING interface_id=%d\n", interface_id);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].interface_id, id);
if (name) {
- switch_set_string(SKYPIAX_CONFIGS[span_id].name, name);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, name);
} else {
- switch_set_string(SKYPIAX_CONFIGS[span_id].name, "N/A");
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A");
}
- switch_set_string(SKYPIAX_CONFIGS[span_id].X11_display, X11_display);
- switch_set_string(SKYPIAX_CONFIGS[span_id].context, context);
- switch_set_string(SKYPIAX_CONFIGS[span_id].dialplan, dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].X11_display=%s\n", span_id, SKYPIAX_CONFIGS[span_id].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].name=%s\n", span_id, SKYPIAX_CONFIGS[span_id].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].context=%s\n", span_id, SKYPIAX_CONFIGS[span_id].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].dialplan=%s\n", span_id, SKYPIAX_CONFIGS[span_id].dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STARTING span_id=%d\n", span_id);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].context, context);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].name=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].context=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id);
if(1)
@@ -2310,7 +2310,7 @@
switch_threadattr_create(&thd_attr, module_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_CONFIGS[span_id], module_pool);
+ switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
usleep(100000);
@@ -2322,31 +2322,31 @@
switch_threadattr_create(&thd_attr, module_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, &SKYPIAX_CONFIGS[span_id], module_pool);
+ switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
usleep(1000000);
-skypiax_skypeaudio_init(&SKYPIAX_CONFIGS[span_id]);
+skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED span_id=%d\n", span_id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED interface_id=%d\n", interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", span_id, SKYPIAX_MAX_INTERFACES);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", interface_id, SKYPIAX_MAX_INTERFACES);
continue;
}
}
for(i=0; i < SKYPIAX_MAX_INTERFACES; i++) {
- if(strlen(SKYPIAX_CONFIGS[i].name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].span_id=%s\n", i, SKYPIAX_CONFIGS[i].span_id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].X11_display=%s\n", i, SKYPIAX_CONFIGS[i].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].name=%s\n", i, SKYPIAX_CONFIGS[i].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].context=%s\n", i, SKYPIAX_CONFIGS[i].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].dialplan=%s\n", i, SKYPIAX_CONFIGS[i].dialplan);
+ if(strlen(SKYPIAX_INTERFACES[i].name)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i, SKYPIAX_INTERFACES[i].interface_id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i, SKYPIAX_INTERFACES[i].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].name=%s\n", i, i, SKYPIAX_INTERFACES[i].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].context=%s\n", i, i, SKYPIAX_INTERFACES[i].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i, SKYPIAX_INTERFACES[i].dialplan);
}
}
}
@@ -2358,10 +2358,13 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
module_pool = pool;
+ memset(&globals, '\0', sizeof(globals));
+ memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
+
#ifndef _WINDOWS_ //FIXME
if (!XInitThreads()) {
ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
@@ -2412,7 +2415,7 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- skypiax_config_t *p;
+ skypiax_interface_t *p;
char msg_to_skype[256];
channel = switch_core_session_get_channel(session);
More information about the Freeswitch-branches
mailing list