[Freeswitch-branches] [commit] r10307 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Sun Nov 9 21:56:22 PST 2008
Author: gmaruzz
Date: Mon Nov 10 00:56:20 2008
New Revision: 10307
Log:
skypiax: first incoming call connected (answered by FS), no audio yet, crashes on FS shutdown
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 Mon Nov 10 00:56:20 2008
@@ -20,6 +20,56 @@
#define SKYPIAX_TMP_LOG NULL, (unsigned long)55, __LINE__, "none", -1, -2, -3
+/*********************************/
+#define AST_CAUSE_NORMAL 1
+/*********************************/
+#define AST_FRAME_DTMF 1
+/*********************************/
+#define AST_CONTROL_RINGING 1
+#define AST_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
+/*********************************/
+/* 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_ACTIVE 300
+#define CALLFLOW_INCOMING_HANGUP 100
+#define CALLFLOW_CALL_RELEASED 101
+#define CALLFLOW_CALL_NOCARRIER 102
+#define CALLFLOW_CALL_INFLUX 103
+#define CALLFLOW_CALL_INCOMING 104
+#define CALLFLOW_CALL_FAILED 105
+#define CALLFLOW_CALL_NOSERVICE 106
+#define CALLFLOW_CALL_OUTGOINGRESTRICTED 107
+#define CALLFLOW_CALL_SECURITYFAIL 108
+#define CALLFLOW_CALL_NOANSWER 109
+#define CALLFLOW_STATUS_FINISHED 110
+#define CALLFLOW_STATUS_CANCELLED 111
+#define CALLFLOW_STATUS_FAILED 112
+#define CALLFLOW_STATUS_REFUSED 113
+#define CALLFLOW_STATUS_RINGING 114
+#define CALLFLOW_STATUS_INPROGRESS 115
+#define CALLFLOW_STATUS_UNPLACED 116
+#define CALLFLOW_STATUS_ROUTING 117
+#define CALLFLOW_STATUS_EARLYMEDIA 118
+#define AST_STATE_HANGUP_REQUESTED 200
+ //FIXME CALLFLOW_INCOMING_CALLID to be removed
+#define CALLFLOW_INCOMING_CALLID 1019
+
+/*********************************/
+
+
+
#define SKYPIAX_MAX_INTERFACES 64
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
@@ -1110,6 +1160,511 @@
#endif /* SKYPE_THREAD */
+#define CONTROLDEV_THREAD
+#ifdef CONTROLDEV_THREAD
+#if 1
+
+#define WANT_SKYPE_X11
+int skypiax_skype_write(struct skypiax_config *p, char *msg_to_skype)
+{
+#ifdef __CYGWIN__
+ static char acInputRow[1024];
+ COPYDATASTRUCT oCopyData;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ sprintf(acInputRow, "%s", msg_to_skype);
+ if (option_debug > 1)
+ DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
+ /* send command to skype */
+ oCopyData.dwData = 0;
+ oCopyData.lpData = acInputRow;
+ oCopyData.cbData = strlen(acInputRow) + 1;
+ if (oCopyData.cbData != 1) {
+ if (SendMessage
+ (p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
+ (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle,
+ (LPARAM) & oCopyData) == FALSE) {
+ ERRORA
+ ("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;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ }
+ }
+#else /* __CYGWIN__ */
+#ifdef WANT_SKYPE_X11
+ struct AsteriskHandles *AsteriskHandlesAst;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ AsteriskHandlesAst = &p->AsteriskHandlesAst;
+
+ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+
+ if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) {
+ ERRORA
+ ("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;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ }
+#endif /* WANT_SKYPE_X11 */
+#endif /* __CYGWIN__ */
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return 0;
+
+}
+#endif //0
+
+
+int skypiax_skype_read(struct skypiax_config *p)
+{
+
+ char read_from_pipe[4096];
+ char messaggio[4096];
+ char messaggio_2[4096];
+ char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
+ char **stringp = NULL;
+ int fd;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+ int howmany, i, a;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ memset(read_from_pipe, 0, 4096);
+ memset(messaggio, 0, 4096);
+ memset(messaggio_2, 0, 4096);
+
+ fd = p->AsteriskHandlesAst.fdesc[0];
+ FD_ZERO(&fs);
+ FD_SET(fd, &fs);
+ to.tv_usec = 100;
+ to.tv_sec = 0;
+ rt = select(fd + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
+ howmany =
+ read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
+
+ a = 0;
+ for (i = 0; i < howmany; i++) {
+ messaggio[a] = read_from_pipe[i];
+ a++;
+
+ if (read_from_pipe[i] == '\0') {
+
+ if (option_debug > 1)
+ DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
+ howmany, i, a, messaggio);
+
+#if 0 //FIXME wat's the use of this?
+ if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
+ just authorized */
+ NOTICA
+ ("Please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
+ SKYPIAX_P_LOG);
+ sleep(1);
+ skypiax_skype_write(p, "PROTOCOL 6");
+ usleep(10000);
+ }
+#endif
+
+ if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
+ ERRORA
+ ("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ 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 (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = AST_STATE_DOWN;
+ //FIXME if(p->owner)
+ //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = AST_STATE_DOWN;
+ }
+ }
+
+ strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
+
+ buf = messaggio;
+ stringp = &buf;
+ where = strsep(stringp, " ");
+ if (!where) {
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
+ }
+
+ if (!strcasecmp(messaggio, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[11]); */
+ memset(p->skype_friends, 0, 4096);
+ strncpy(p->skype_friends, &messaggio_2[11], 4095);
+ }
+ if (!strcasecmp(messaggio, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(p->skype_fullname, 0, 512);
+ strncpy(p->skype_fullname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(p->skype_displayname, 0, 512);
+ strncpy(p->skype_displayname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "ERROR")) {
+ ERRORA
+ ("Skype got ERROR: |||%s|||\n",
+ SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ 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 (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = AST_STATE_DOWN;
+ //FIXME if(p->owner){
+ //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME }
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = AST_STATE_DOWN;
+ }
+ }
+ if (!strcasecmp(messaggio, "CALL")) {
+
+ strncpy(obj, where, sizeof(obj) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(id, where, sizeof(id) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(prop, where, sizeof(prop) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(value, where, sizeof(value) - 1);
+
+ where = strsep(stringp, " ");
+
+ if (option_debug > 1)
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
+
+ if (!strcasecmp(prop, "PARTNER_HANDLE")) {
+ strncpy(p->callid_number, value, sizeof(p->callid_number) - 1);
+ return CALLFLOW_INCOMING_RING;
+ }
+ if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
+ snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value,
+ where ? " " : "", where ? where : "");
+ }
+ 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 (!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 (!strcasecmp(prop, "DTMF")) {
+ //FIXME struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+ DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+ //FIXME ast_queue_frame(p->owner, &f2);
+ }
+
+ if (!strcasecmp(prop, "FAILUREREASON")) {
+ /* if (option_debug > 1) */
+ DEBUGA_SKYPE
+ ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
+ if (strcasecmp(id, p->skype_call_id)) {
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ if (option_debug > 1)
+ DEBUGA_SKYPE
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ }
+
+
+ if (!strcasecmp(prop, "STATUS")) {
+
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (p->interface_state != AST_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;
+ /* no owner, no active call, let's answer */
+ skypiax_skype_write(p, "SET AGC OFF");
+ usleep(10000);
+ skypiax_skype_write(p, "SET AEC OFF");
+ usleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_skype_write(p, msg_to_skype);
+ if (option_debug)
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
+ SKYPIAX_P_LOG, id);
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ } else {
+ /* we're owned, we're in a call, let's refuse */
+ sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(10000);
+ DEBUGA_SKYPE
+ ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
+ SKYPIAX_P_LOG, id);
+
+ }
+ } 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);
+ 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);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
+ SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
+
+ } else if (!strcasecmp(value, "FINISHED")) {
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ 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 (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = AST_STATE_DOWN;
+ //FIXME if(p->owner)
+ //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = AST_STATE_DOWN;
+ }
+
+ } else if (!strcasecmp(value, "CANCELLED")) {
+ p->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
+ p->skype_call_id[0] = '\0';
+
+ if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = AST_STATE_DOWN;
+ //FIXME if(p->owner)
+ //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = AST_STATE_DOWN;
+ }
+ } else if (!strcasecmp(value, "FAILED")) {
+ p->skype_callflow = CALLFLOW_STATUS_FAILED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
+ 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;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ //FIXME if(p->owner)
+ //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else if (!strcasecmp(value, "REFUSED")) {
+ if (!strcasecmp(id, p->skype_call_id)) {
+ /* this is the id of the call we are in, probably we generated it */
+ p->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("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->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;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ /* we're here because were us that refused an incoming call */
+ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
+
+ }
+ } else if (!strcasecmp(value, "ROUTING")) {
+ p->skype_callflow = CALLFLOW_STATUS_ROUTING;
+ p->interface_state = AST_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;
+ 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;
+ 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 }
+ if (option_debug > 1)
+ DEBUGA_SKYPE("skype_call: %s AST_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
+ id);
+
+ //FIXME if (p->owner)
+ if (1) {
+ char msg_to_skype[1024];
+ if (!p->tcp_cli_thread) {
+#ifdef NOTDEF
+ if (ast_pthread_create
+ (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
+ ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ } else {
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ }
+#endif //NOTDEF
+ }
+
+ usleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(100000);
+ }
+
+ p->skype_callflow = AST_STATE_UP;
+ } else {
+ WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
+ id, value);
+
+ }
+ } //STATUS
+
+ } //CALL
+
+ a = 0;
+ } //message end
+ } //read_from_pipe
+
+ }
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return 0;
+}
+
+/*!
+ * \brief This thread runs during a call, and monitor the interface serial port for signaling, like hangup, caller id, etc
+ *
+ */
+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;
+ int res;
+
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+
+ DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, (void *)p);
+
+
+ while (1) {
+ usleep(1000);
+ res = skypiax_skype_read(p);
+#if 0
+ if (res == CALLFLOW_INCOMING_HANGUP) {
+ //if (option_debug)
+ DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
+ if (p->owner) {
+ pthread_testcancel();
+ ast_queue_control(p->owner, AST_CONTROL_HANGUP);
+ }
+ }
+#endif
+ }
+
+ //if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ //}
+ return NULL;
+
+}
+
+
+#endif // CONTROLDEV_THREAD
static switch_status_t load_config(void)
{
@@ -1280,6 +1835,19 @@
switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_CONFIGS[span_id], module_pool);
}
+usleep(100000);
+if(1)
+{
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr = NULL;
+
+ 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);
+}
+
+
usleep(1000000);
skypiax_skypeaudio_init(&SKYPIAX_CONFIGS[span_id]);
More information about the Freeswitch-branches
mailing list