From gmaruzz at freeswitch.org Sun Feb 1 00:36:43 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 02:36:43 -0600 Subject: [Freeswitch-branches] [commit] r11585 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 1 02:36:43 2009 New Revision: 11585 Log: skypiax: FS: give back NORMAL_TEMPORARY_FAILURE when trying to originate a call using a non-idle channel Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Sun Feb 1 02:36:43 2009 @@ -500,6 +500,10 @@ (strncmp (globals.SKYPIAX_INTERFACES[i].name, interface_name, strlen(interface_name)) == 0)) { + if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)){ + DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str); + return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE ; + } DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name); From gmaruzz at freeswitch.org Sun Feb 1 00:54:26 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 02:54:26 -0600 Subject: [Freeswitch-branches] [commit] r11586 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 1 02:54:26 2009 New Revision: 11586 Log: skypiax: FS: added a clearing of session_uuid_string on channel_on_hangup, just to be sure Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Sun Feb 1 02:54:26 2009 @@ -175,6 +175,7 @@ switch_core_codec_destroy(&tech_pvt->write_codec); } + memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str)); DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, switch_channel_get_name(channel)); switch_mutex_lock(globals.mutex); globals.calls--; From gmaruzz at freeswitch.org Sun Feb 1 02:01:04 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 04:01:04 -0600 Subject: [Freeswitch-branches] [commit] r11587 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 1 04:01:04 2009 New Revision: 11587 Log: skypiax: FS: oooops, added a session_destroy when giving back NORMAL_TEMPORARY_FAILURE when trying to originate a call using a non-idle channel Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Sun Feb 1 04:01:04 2009 @@ -503,6 +503,7 @@ strlen(interface_name)) == 0)) { if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)){ DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str); + switch_core_session_destroy(new_session); return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE ; } From gmaruzz at freeswitch.org Sun Feb 1 02:37:51 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 04:37:51 -0600 Subject: [Freeswitch-branches] [commit] r11588 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Sun Feb 1 04:37:51 2009 New Revision: 11588 Log: skypiax: incoming audio works on asterisk. Only one interface, no configuration Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c Sun Feb 1 04:37:51 2009 @@ -481,6 +481,9 @@ } #endif /* WIN32 */ +/* the pipe is the audio fd for asterisk to poll on during a call */ + tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; + if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } From gmaruzz at freeswitch.org Sun Feb 1 15:43:35 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 17:43:35 -0600 Subject: [Freeswitch-branches] [commit] r11590 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Sun Feb 1 17:43:35 2009 New Revision: 11590 Log: skypiax: now multichannel on *, at least on linux. Need tests Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile Sun Feb 1 17:43:35 2009 @@ -21,7 +21,7 @@ #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_160/include #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_12/include #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_14/include -AST_INCLUDE_DIR=/home/maruzz/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include +AST_INCLUDE_DIR=/home/user/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include #ASTERISK CFLAGS+=-DASTERISK Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Sun Feb 1 17:43:35 2009 @@ -1278,6 +1278,9 @@ M_STR("context", tmp->context) M_STR("language", tmp->language) M_STR("extension", tmp->exten) + M_STR("X11_display", tmp->X11_display) + M_UINT("tcp_cli_port", tmp->tcp_cli_port) + M_UINT("tcp_srv_port", tmp->tcp_srv_port) M_F("playback_boost", skypiax_store_boost(v->value, &tmp->playback_boost)) M_F("capture_boost", skypiax_store_boost(v->value, &tmp->capture_boost)) M_UINT("skypiax_dir_entry_extension_prefix", @@ -1388,29 +1391,6 @@ DEBUGA_SOUND("playback_boost is %f\n", SKYPIAX_TMP_LOG, tmp->playback_boost); DEBUGA_SOUND("capture_boost is %f\n", SKYPIAX_TMP_LOG, tmp->capture_boost); } - /* if skype is true for this interface, let's check if another interface has skype true */ - if (tmp->skype) { - struct skypiax_pvt *p = NULL, *p2 = NULL; - /* lock the skypiax_iflock, maybe unneeded */ - LOKKA(&skypiax_iflock); - p = skypiax_iflist; - /* for each pvt in the interfaces list (skypiax_iflist) */ - while (p) { - p2 = p->next; - /* if another interface has skype true */ - if (p->skype) { - ERRORA - ("This interface (category '[%s]') has 'skype=yes' in config, but up in skypiax.conf config file the interface category '[%s]' has yet 'skype=yes'. Only one interface at time can support skype. I'm sure, I wrote it ;). Setting 'skype=no' for interface category '[%s] and continuing\n", - SKYPIAX_P_LOG, tmp->name, p->name, tmp->name); - /* set this interface's skype to false */ - tmp->skype = 0; - } - /* next interface, please */ - p = p2; - } - /* unlock the skypiax_iflock */ - UNLOCKA(&skypiax_iflock); - } /* initialize the soundcard channels (input and output) used by this interface (a multichannel soundcard can be used by multiple interfaces), optionally starting the sound managing threads */ res = skypiax_sound_init(tmp); if (res == -1) { From gmaruzz at freeswitch.org Sun Feb 1 16:59:20 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 01 Feb 2009 18:59:20 -0600 Subject: [Freeswitch-branches] [commit] r11591 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Sun Feb 1 18:59:20 2009 New Revision: 11591 Log: skypiax: on *, incoming and outbound calls, multichannel. Concurrent calls work. Audio only on the first call for each channel. Probably because the audio threads with the skype client are not killed when call is ended, etc etc. Anyway, it is working as a proof of concept. Now is too late, let's leave something for tomorrow night ;-) Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Sun Feb 1 18:59:20 2009 @@ -684,6 +684,7 @@ DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr); + strcpy(p->session_uuid_str, "dialing"); status = skypiax_skype_call(p, dstr, timeout); if (status) { WARNINGA("skypiax_call dialing failed: %d!\n", SKYPIAX_P_LOG, status); @@ -2203,6 +2204,11 @@ switch_core_session_rwunlock(session); #endif + + if (p->owner) { + ast_queue_control(p->owner, AST_CONTROL_ANSWER); + } + NOTICA("HERE!\n", SKYPIAX_P_LOG); return 0; Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf Sun Feb 1 18:59:20 2009 @@ -50,6 +50,62 @@ ;debug_monitorlocks=yes skype=yes ; legacy setting, leave it to yes +X11_display=:101 +tcp_cli_port=11234 +tcp_srv_port=11235 +;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;; +; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels +; tweak it if you get horrible (or not hearable) sound +; +;boost can be positive or negative (-40 to +40) in db +;experiment to find which values are best for your computer +playback_boost=0 ; +capture_boost=0 ; + +[skypeclient2] +;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;; +; general settings, valid on all platforms +; +; +; Default language +; +language=en +; +; Default context (in extensions.conf, can be overridden with @context syntax) +; +context=default +; +; Default extension (in extensions.conf) where incoming calls land +; +extension=s +; +;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;; +; Debugging settings, valid globally for all interfaces on all platforms +; +; the debug values are global for all the interfaces. +; +; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax +; +; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch +; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages +; +; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all +; debug_all activate all possible debugging info +; +;debug_all=yes +debug_skype=yes +debug_pbx=yes +;debug_sound=yes +;debug_locks=yes +;debug_monitorlocks=yes + +skype=yes ; legacy setting, leave it to yes +X11_display=:102 +tcp_cli_port=11236 +tcp_srv_port=11237 ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels From intralanman at freeswitch.org Mon Feb 2 19:19:16 2009 From: intralanman at freeswitch.org (FreeSWITCH SVN) Date: Mon, 02 Feb 2009 21:19:16 -0600 Subject: [Freeswitch-branches] [commit] r11607 - freeswitch/branches/jskopis Message-ID: Author: intralanman Date: Mon Feb 2 21:19:16 2009 New Revision: 11607 Log: adding branch for skopii... hopefully in the right place this time ;-) Added: freeswitch/branches/jskopis/ From gmaruzz at freeswitch.org Tue Feb 3 15:39:17 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 03 Feb 2009 17:39:17 -0600 Subject: [Freeswitch-branches] [commit] r11627 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Tue Feb 3 17:39:16 2009 New Revision: 11627 Log: skypiax: works on *. Starting tomorrow, cleaning all the code, making it readable, washing, rinsing, repeat, repeat, repeat... :-) Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Tue Feb 3 17:39:16 2009 @@ -12,6 +12,7 @@ /* GLOBAL VARIABLES */ int running = 1; +int skypiax_dir_entry_extension=1; //FIXME one var for each interface! char skypiax_console_active_array[50] = ""; char *skypiax_console_active = skypiax_console_active_array; /*! \brief Count of active channels for this module */ @@ -2085,7 +2086,7 @@ } int start_audio_threads(private_t *p) { - if (!p->tcp_srv_thread) { + //if (!p->tcp_srv_thread) { if (ast_pthread_create (&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) { ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG); @@ -2096,8 +2097,8 @@ } else { DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); } - } - if (!p->tcp_cli_thread) { + //} + //if (!p->tcp_cli_thread) { 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); @@ -2108,7 +2109,7 @@ } else { DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); } - } + //} #ifdef NOTDEF @@ -2287,6 +2288,377 @@ return RESULT_SUCCESS; } +int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]) +{ + //int res; + struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); + //char list_command[64]; + char fn[256]; + char date[256] = ""; + time_t t; + char *configfile = SKYPIAX_DIR_CONFIG; + int add_to_skypiax_dir_conf = 1; + //int fromskype = 0; + //int fromcell = 0; + +#if 0 + if(directoriax_entry_extension){ + skypiax_dir_entry_extension=directoriax_entry_extension; + }else{ + ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); + return RESULT_SUCCESS; + } +#endif + + if (argc != 2) + return RESULT_SHOWUSAGE; + if (!p) { + ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n"); + return RESULT_SUCCESS; + } + + if (!strcasecmp(argv[1], "add")) + add_to_skypiax_dir_conf = 1; + else if (!strcasecmp(argv[1], "replace")) + add_to_skypiax_dir_conf = 0; + else { + ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n"); + return RESULT_SHOWUSAGE; + } + +#if 0 + if (!strcasecmp(argv[2], "fromskype")) + fromskype = 1; + else if (!strcasecmp(argv[2], "fromcell")) + fromcell = 1; + else { + ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n"); + return RESULT_SHOWUSAGE; + } + + if (fromcell) { + ast_cli(fd, + "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n"); + //fclose(p->phonebook_writing_fp); + //skypiax_dir_create_extensions(); + return RESULT_SUCCESS; + } + + if (fromskype) + if (!p->skype) { + ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n"); + //fclose(p->phonebook_writing_fp); + //skypiax_dir_create_extensions(); + return RESULT_SUCCESS; + } + + if (fromcell || fromskype) + if (argc != 3) { + ast_cli(fd, + "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n"); + return RESULT_SHOWUSAGE; + } +#endif + + /*******************************************************************************************/ + + if (configfile[0] == '/') { + ast_copy_string(fn, configfile, sizeof(fn)); + } else { + snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); + } + if (option_debug) + NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); + time(&t); + ast_copy_string(date, ctime(&t), sizeof(date)); + + if (add_to_skypiax_dir_conf) + p->phonebook_writing_fp = fopen(fn, "a+"); + else + p->phonebook_writing_fp = fopen(fn, "w+"); + + if (p->phonebook_writing_fp) { + if (add_to_skypiax_dir_conf) { + if (option_debug) + NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); + fprintf(p->phonebook_writing_fp, ";!\n"); + fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); + fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); + fprintf(p->phonebook_writing_fp, ";!\n"); + } else { + if (option_debug) + NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); + fprintf(p->phonebook_writing_fp, ";!\n"); + fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); + fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn); + fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date); + fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__); + fprintf(p->phonebook_writing_fp, ";!\n"); + fprintf(p->phonebook_writing_fp, "[general]\n\n"); + fprintf(p->phonebook_writing_fp, "[default]\n"); + } + + /*******************************************************************************************/ + //if (fromskype) { + if (p->skype) { + WARNINGA + ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", + SKYPIAX_P_LOG); + if (p->skype_thread != AST_PTHREADT_NULL) { + char msg_to_skype[1024]; + + p->skype_friends[0] = '\0'; + sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); + if (skypiax_skype_write(p, msg_to_skype) < 0) { + return -1; + } + + int friends_count = 0; + while (p->skype_friends[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + friends_count++; + if (friends_count > 20000) { + return -1; /* FIXME */ + } + } + + } + + if (p->skype_thread != AST_PTHREADT_NULL) { + char msg_to_skype[1024]; + + if (p->skype_friends[0] != '\0') { + char *buf, *where; + char **stringp; + int skype_dir_file_written = 0; + + buf = p->skype_friends; + stringp = &buf; + where = strsep(stringp, ", "); + while (where) { + if (where[0] != '\0') { + /* + * So, we have the Skype username (the HANDLE, I think is called). + * But we want to call the names we see in the Skype contact list + * So, let's check the DISPLAYNAME (the end user modified contact name) + * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME + * if the end user has not modify it) + * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the + * Skipe username (the HANDLE) + */ + + p->skype_displayname[0] = '\0'; + sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); + skypiax_skype_write(p, msg_to_skype); + int displayname_count = 0; + while (p->skype_displayname[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + displayname_count++; + if (displayname_count > 20000) + return -1; /* FIXME */ + } + if (p->skype_displayname[0] != '\0') { + char *where2; + char sanitized[300]; + + sanitized[0] = '\0'; + + where2 = strstr(p->skype_displayname, "DISPLAYNAME "); + if (where2) { + + /* there can be some *smart* that makes a displayname + * that is different than firstlast, */ + /* maybe initials, simbols, slashes, + * something smartish... let's check */ + + if (where2[12] != '\0') { + int i = 12; + int x = 0; + int spaces = 0; + int last_char_was_space = 0; + + for (i = 12; i < strlen(where2) && x < 299; i++) { + if (!isalnum(where2[i])) { + if (!isblank(where2[i])) { + /* bad char */ + continue; + } + /* is a space */ + if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ + continue; + last_char_was_space = 1; + sanitized[x] = ' '; + x++; + continue; + } + /* is alphanum */ + last_char_was_space = 0; + sanitized[x] = where2[i]; + x++; + continue; + } + + sanitized[x] = '\0'; + if (spaces == 0) { + } + DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", + SKYPIAX_P_LOG, sanitized, where, &where2[12]); + } + + if (where2[12] != '\0') { + skypiax_dir_entry_extension++; + if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "2", + skypiax_dir_entry_extension, "yes", "not_specified"); + } else { /* is a skype name */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "1", + skypiax_dir_entry_extension, "yes", "not_specified"); + } + skype_dir_file_written = 1; + + } + } + } + p->skype_displayname[0] = '\0'; + + p->skype_fullname[0] = '\0'; + sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); + skypiax_skype_write(p, msg_to_skype); + int fullname_count = 0; + while (p->skype_fullname[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + fullname_count++; + if (fullname_count > 20000) + return -1; /* FIXME */ + } + if (p->skype_fullname[0] != '\0') { + char *where2; + char sanitized[300]; + + where2 = strstr(p->skype_fullname, "FULLNAME "); + if (where2) { + + /* there can be some *smart* that makes a fullname + * that is different than firstlast, */ + /* maybe initials, simbols, slashes, + * something smartish... let's check */ + + if (where2[9] != '\0') { + int i = 9; + int x = 0; + int spaces = 0; + int last_char_was_space = 0; + + for (i = 9; i < strlen(where2) && x < 299; i++) { + if (!isalnum(where2[i])) { + if (!isblank(where2[i])) { + /* bad char */ + continue; + } + /* is a space */ + if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ + continue; + last_char_was_space = 1; + sanitized[x] = ' '; + x++; + continue; + } + /* alphanum */ + last_char_was_space = 0; + sanitized[x] = where2[i]; + x++; + continue; + } + + sanitized[x] = '\0'; + if (spaces == 0) { + } + DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", + SKYPIAX_P_LOG, sanitized, where, &where2[9]); + } + + if (skype_dir_file_written == 0) { + skypiax_dir_entry_extension++; + if (where2[9] != '\0') { + if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "2", + skypiax_dir_entry_extension, "yes", "not_specified"); + } else { /* is a skype name */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "1", + skypiax_dir_entry_extension, "yes", "not_specified"); + + } + + } else { + if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, where, "no", + p->skypiax_dir_entry_extension_prefix, "2", + skypiax_dir_entry_extension, "yes", "not_specified"); + } else { /* is a skype name */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, where, "no", + p->skypiax_dir_entry_extension_prefix, "1", + skypiax_dir_entry_extension, "yes", "not_specified"); + + } + } + } + + skype_dir_file_written = 0; + + } + + } + p->skype_fullname[0] = '\0'; + + } + where = strsep(stringp, ", "); + } + + p->skype_friends[0] = '\0'; + } + } + } else { + + ast_cli(fd, + "Skype not configured on the 'current' console, not importing from Skype client!\n"); + } + //} + /*******************************************************************************************/ + /*******************************************************************************************/ + } else { + ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn); + ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG, + fn); + return RESULT_FAILURE; + } + + fclose(p->phonebook_writing_fp); + //skypiax_dir_create_extensions(); + + return RESULT_SUCCESS; +} /************************************************/ #ifdef ASTERISK_VERSION_1_4 #ifndef AST_MODULE Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Tue Feb 3 17:39:16 2009 @@ -111,6 +111,7 @@ /* DEFINITIONS */ #define SAMPLERATE_SKYPIAX 8000 #define SAMPLES_PER_FRAME SAMPLERATE_SKYPIAX/50 +#define SKYPIAX_DIR_CONFIG "directoriax.conf" /* LUIGI RIZZO's magic */ /* boost support. BOOST_SCALE * 10 ^(BOOST_MAX/20) must Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c Tue Feb 3 17:39:16 2009 @@ -3,7 +3,6 @@ #ifdef ASTERISK #define skypiax_sleep usleep #define tech_pvt p -#define SKYPIAX_DIR_CONFIG "directoriax.conf" extern int skypiax_debug; #define skypiax_file_write switch_file_write #define skypiax_file_read switch_file_read @@ -19,8 +18,6 @@ extern int option_debug; extern int running; -/* GLOBALS */ -int skypiax_dir_entry_extension=1; /*************************************/ #ifndef WIN32 XErrorHandler old_handler = 0; @@ -1638,376 +1635,3 @@ return 0; } -#ifdef ASTERISK -int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]) -{ - //int res; - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - //char list_command[64]; - char fn[256]; - char date[256] = ""; - time_t t; - char *configfile = SKYPIAX_DIR_CONFIG; - int add_to_skypiax_dir_conf = 1; - //int fromskype = 0; - //int fromcell = 0; - -#if 0 - if(directoriax_entry_extension){ - skypiax_dir_entry_extension=directoriax_entry_extension; - }else{ - ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); - return RESULT_SUCCESS; - } -#endif - - if (argc != 2) - return RESULT_SHOWUSAGE; - if (!p) { - ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (!strcasecmp(argv[1], "add")) - add_to_skypiax_dir_conf = 1; - else if (!strcasecmp(argv[1], "replace")) - add_to_skypiax_dir_conf = 0; - else { - ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n"); - return RESULT_SHOWUSAGE; - } - -#if 0 - if (!strcasecmp(argv[2], "fromskype")) - fromskype = 1; - else if (!strcasecmp(argv[2], "fromcell")) - fromcell = 1; - else { - ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n"); - return RESULT_SHOWUSAGE; - } - - if (fromcell) { - ast_cli(fd, - "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromskype) - if (!p->skype) { - ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromcell || fromskype) - if (argc != 3) { - ast_cli(fd, - "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n"); - return RESULT_SHOWUSAGE; - } -#endif - - /*******************************************************************************************/ - - if (configfile[0] == '/') { - ast_copy_string(fn, configfile, sizeof(fn)); - } else { - snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); - } - if (option_debug) - NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); - time(&t); - ast_copy_string(date, ctime(&t), sizeof(date)); - - if (add_to_skypiax_dir_conf) - p->phonebook_writing_fp = fopen(fn, "a+"); - else - p->phonebook_writing_fp = fopen(fn, "w+"); - - if (p->phonebook_writing_fp) { - if (add_to_skypiax_dir_conf) { - if (option_debug) - NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - } else { - if (option_debug) - NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); - fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn); - fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, "[general]\n\n"); - fprintf(p->phonebook_writing_fp, "[default]\n"); - } - - /*******************************************************************************************/ - //if (fromskype) { - if (p->skype) { - WARNINGA - ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", - SKYPIAX_P_LOG); - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - p->skype_friends[0] = '\0'; - sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); - if (skypiax_skype_write(p, msg_to_skype) < 0) { - return -1; - } - - int friends_count = 0; - while (p->skype_friends[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - friends_count++; - if (friends_count > 20000) { - return -1; /* FIXME */ - } - } - - } - - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - if (p->skype_friends[0] != '\0') { - char *buf, *where; - char **stringp; - int skype_dir_file_written = 0; - - buf = p->skype_friends; - stringp = &buf; - where = strsep(stringp, ", "); - while (where) { - if (where[0] != '\0') { - /* - * So, we have the Skype username (the HANDLE, I think is called). - * But we want to call the names we see in the Skype contact list - * So, let's check the DISPLAYNAME (the end user modified contact name) - * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME - * if the end user has not modify it) - * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the - * Skipe username (the HANDLE) - */ - - p->skype_displayname[0] = '\0'; - sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); - skypiax_skype_write(p, msg_to_skype); - int displayname_count = 0; - while (p->skype_displayname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - displayname_count++; - if (displayname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_displayname[0] != '\0') { - char *where2; - char sanitized[300]; - - sanitized[0] = '\0'; - - where2 = strstr(p->skype_displayname, "DISPLAYNAME "); - if (where2) { - - /* there can be some *smart* that makes a displayname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[12] != '\0') { - int i = 12; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 12; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* is alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[12]); - } - - if (where2[12] != '\0') { - skypiax_dir_entry_extension++; - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - } - skype_dir_file_written = 1; - - } - } - } - p->skype_displayname[0] = '\0'; - - p->skype_fullname[0] = '\0'; - sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); - skypiax_skype_write(p, msg_to_skype); - int fullname_count = 0; - while (p->skype_fullname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - fullname_count++; - if (fullname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_fullname[0] != '\0') { - char *where2; - char sanitized[300]; - - where2 = strstr(p->skype_fullname, "FULLNAME "); - if (where2) { - - /* there can be some *smart* that makes a fullname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[9] != '\0') { - int i = 9; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 9; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[9]); - } - - if (skype_dir_file_written == 0) { - skypiax_dir_entry_extension++; - if (where2[9] != '\0') { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - - } - - } else { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - - } - } - } - - skype_dir_file_written = 0; - - } - - } - p->skype_fullname[0] = '\0'; - - } - where = strsep(stringp, ", "); - } - - p->skype_friends[0] = '\0'; - } - } - } else { - - ast_cli(fd, - "Skype not configured on the 'current' console, not importing from Skype client!\n"); - } - //} - /*******************************************************************************************/ - /*******************************************************************************************/ - } else { - ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn); - ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG, - fn); - return RESULT_FAILURE; - } - - fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - - return RESULT_SUCCESS; -} -#endif /* ASTERISK */ From jskopis at freeswitch.org Wed Feb 4 19:32:38 2009 From: jskopis at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Feb 2009 21:32:38 -0600 Subject: [Freeswitch-branches] [commit] r11650 - freeswitch/branches/jskopis/trunk Message-ID: Author: jskopis Date: Wed Feb 4 21:32:38 2009 New Revision: 11650 Log: copying trunk Added: freeswitch/branches/jskopis/trunk/ - copied from r11649, /freeswitch/trunk/ From jskopis at freeswitch.org Wed Feb 4 19:36:06 2009 From: jskopis at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Feb 2009 21:36:06 -0600 Subject: [Freeswitch-branches] [commit] r11651 - freeswitch/branches/jskopis/trunk Message-ID: Author: jskopis Date: Wed Feb 4 21:36:06 2009 New Revision: 11651 Log: whoops Removed: freeswitch/branches/jskopis/trunk/ From jskopis at freeswitch.org Wed Feb 4 19:36:18 2009 From: jskopis at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Feb 2009 21:36:18 -0600 Subject: [Freeswitch-branches] [commit] r11652 - freeswitch/branches/jskopis/trunk Message-ID: Author: jskopis Date: Wed Feb 4 21:36:18 2009 New Revision: 11652 Log: copying trunk Added: freeswitch/branches/jskopis/trunk/ - copied from r11651, /freeswitch/trunk/ From jskopis at freeswitch.org Wed Feb 4 19:40:45 2009 From: jskopis at freeswitch.org (FreeSWITCH SVN) Date: Wed, 04 Feb 2009 21:40:45 -0600 Subject: [Freeswitch-branches] [commit] r11653 - freeswitch/branches/jskopis/trunk Message-ID: Author: jskopis Date: Wed Feb 4 21:40:44 2009 New Revision: 11653 Log: whoops Removed: freeswitch/branches/jskopis/trunk/ From gmaruzz at freeswitch.org Fri Feb 6 11:37:00 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 06 Feb 2009 13:37:00 -0600 Subject: [Freeswitch-branches] [commit] r11672 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Fri Feb 6 13:36:59 2009 New Revision: 11672 Log: skypiax: if don't start all interfaces, module don't load Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Fri Feb 6 13:36:59 2009 @@ -905,7 +905,7 @@ skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]); i=0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 6000) { // 60sec + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME switch_sleep(1000); i++; } @@ -913,7 +913,7 @@ NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id); } else { ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id); - break; + return SWITCH_STATUS_FALSE; } } else { @@ -961,7 +961,8 @@ running = 1; - load_config(); + if (load_config() != SWITCH_STATUS_SUCCESS) + return SWITCH_STATUS_FALSE; *module_interface = switch_loadable_module_create_module_interface(pool, modname); skypiax_endpoint_interface = From gmaruzz at freeswitch.org Fri Feb 6 11:39:31 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 06 Feb 2009 13:39:31 -0600 Subject: [Freeswitch-branches] [commit] r11673 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Fri Feb 6 13:39:31 2009 New Revision: 11673 Log: skypiax: on asterisk subdir removed skypiax_protocol.c, will be a symlink to ../skypiax_protocol.c Removed: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c From gmaruzz at freeswitch.org Fri Feb 6 11:40:22 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 06 Feb 2009 13:40:22 -0600 Subject: [Freeswitch-branches] [commit] r11674 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Fri Feb 6 13:40:22 2009 New Revision: 11674 Log: skypiax: on asterisk subdir added symlink to ../skypiax_protocol.c Added: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c (contents, props changed) Added: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c ============================================================================== --- (empty file) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax_protocol.c Fri Feb 6 13:40:22 2009 @@ -0,0 +1 @@ +link ../skypiax_protocol.c \ No newline at end of file From gmaruzz at freeswitch.org Fri Feb 6 11:45:39 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 06 Feb 2009 13:45:39 -0600 Subject: [Freeswitch-branches] [commit] r11675 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Fri Feb 6 13:45:38 2009 New Revision: 11675 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile Fri Feb 6 13:45:38 2009 @@ -21,7 +21,7 @@ #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_160/include #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_12/include #AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_14/include -AST_INCLUDE_DIR=/home/user/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include +AST_INCLUDE_DIR=/home/maruzz/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include #ASTERISK CFLAGS+=-DASTERISK Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Fri Feb 6 13:45:38 2009 @@ -188,7 +188,6 @@ char language[80]; /*!< \brief default Asterisk dialplan language for this interface */ char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */ int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */ - switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ char callid_name[50]; char callid_number[50]; double playback_boost; @@ -205,9 +204,11 @@ #ifdef WIN32 switch_file_t *audiopipe[2]; switch_file_t *audioskypepipe[2]; + switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ #else /* WIN32 */ int audiopipe[2]; int audioskypepipe[2]; + int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ #endif /* WIN32 */ switch_thread_t *tcp_srv_thread; switch_thread_t *tcp_cli_thread; Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Fri Feb 6 13:45:38 2009 @@ -3,7 +3,6 @@ #ifdef ASTERISK #define skypiax_sleep usleep #define tech_pvt p -#define SKYPIAX_DIR_CONFIG "directoriax.conf" extern int skypiax_debug; #define skypiax_file_write switch_file_write #define skypiax_file_read switch_file_read @@ -19,8 +18,6 @@ extern int option_debug; extern int running; -/* GLOBALS */ -int skypiax_dir_entry_extension=1; /*************************************/ #ifndef WIN32 XErrorHandler old_handler = 0; @@ -481,6 +478,9 @@ } #endif /* WIN32 */ +/* the pipe is the audio fd for asterisk to poll on during a call */ + tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; + if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -1635,376 +1635,3 @@ return 0; } -#ifdef ASTERISK -int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]) -{ - //int res; - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - //char list_command[64]; - char fn[256]; - char date[256] = ""; - time_t t; - char *configfile = SKYPIAX_DIR_CONFIG; - int add_to_skypiax_dir_conf = 1; - //int fromskype = 0; - //int fromcell = 0; - -#if 0 - if(directoriax_entry_extension){ - skypiax_dir_entry_extension=directoriax_entry_extension; - }else{ - ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); - return RESULT_SUCCESS; - } -#endif - - if (argc != 2) - return RESULT_SHOWUSAGE; - if (!p) { - ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (!strcasecmp(argv[1], "add")) - add_to_skypiax_dir_conf = 1; - else if (!strcasecmp(argv[1], "replace")) - add_to_skypiax_dir_conf = 0; - else { - ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n"); - return RESULT_SHOWUSAGE; - } - -#if 0 - if (!strcasecmp(argv[2], "fromskype")) - fromskype = 1; - else if (!strcasecmp(argv[2], "fromcell")) - fromcell = 1; - else { - ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n"); - return RESULT_SHOWUSAGE; - } - - if (fromcell) { - ast_cli(fd, - "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromskype) - if (!p->skype) { - ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromcell || fromskype) - if (argc != 3) { - ast_cli(fd, - "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n"); - return RESULT_SHOWUSAGE; - } -#endif - - /*******************************************************************************************/ - - if (configfile[0] == '/') { - ast_copy_string(fn, configfile, sizeof(fn)); - } else { - snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); - } - if (option_debug) - NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); - time(&t); - ast_copy_string(date, ctime(&t), sizeof(date)); - - if (add_to_skypiax_dir_conf) - p->phonebook_writing_fp = fopen(fn, "a+"); - else - p->phonebook_writing_fp = fopen(fn, "w+"); - - if (p->phonebook_writing_fp) { - if (add_to_skypiax_dir_conf) { - if (option_debug) - NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - } else { - if (option_debug) - NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); - fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn); - fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, "[general]\n\n"); - fprintf(p->phonebook_writing_fp, "[default]\n"); - } - - /*******************************************************************************************/ - //if (fromskype) { - if (p->skype) { - WARNINGA - ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", - SKYPIAX_P_LOG); - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - p->skype_friends[0] = '\0'; - sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); - if (skypiax_skype_write(p, msg_to_skype) < 0) { - return -1; - } - - int friends_count = 0; - while (p->skype_friends[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - friends_count++; - if (friends_count > 20000) { - return -1; /* FIXME */ - } - } - - } - - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - if (p->skype_friends[0] != '\0') { - char *buf, *where; - char **stringp; - int skype_dir_file_written = 0; - - buf = p->skype_friends; - stringp = &buf; - where = strsep(stringp, ", "); - while (where) { - if (where[0] != '\0') { - /* - * So, we have the Skype username (the HANDLE, I think is called). - * But we want to call the names we see in the Skype contact list - * So, let's check the DISPLAYNAME (the end user modified contact name) - * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME - * if the end user has not modify it) - * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the - * Skipe username (the HANDLE) - */ - - p->skype_displayname[0] = '\0'; - sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); - skypiax_skype_write(p, msg_to_skype); - int displayname_count = 0; - while (p->skype_displayname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - displayname_count++; - if (displayname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_displayname[0] != '\0') { - char *where2; - char sanitized[300]; - - sanitized[0] = '\0'; - - where2 = strstr(p->skype_displayname, "DISPLAYNAME "); - if (where2) { - - /* there can be some *smart* that makes a displayname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[12] != '\0') { - int i = 12; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 12; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* is alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[12]); - } - - if (where2[12] != '\0') { - skypiax_dir_entry_extension++; - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - } - skype_dir_file_written = 1; - - } - } - } - p->skype_displayname[0] = '\0'; - - p->skype_fullname[0] = '\0'; - sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); - skypiax_skype_write(p, msg_to_skype); - int fullname_count = 0; - while (p->skype_fullname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - fullname_count++; - if (fullname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_fullname[0] != '\0') { - char *where2; - char sanitized[300]; - - where2 = strstr(p->skype_fullname, "FULLNAME "); - if (where2) { - - /* there can be some *smart* that makes a fullname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[9] != '\0') { - int i = 9; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 9; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[9]); - } - - if (skype_dir_file_written == 0) { - skypiax_dir_entry_extension++; - if (where2[9] != '\0') { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - - } - - } else { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - - } - } - } - - skype_dir_file_written = 0; - - } - - } - p->skype_fullname[0] = '\0'; - - } - where = strsep(stringp, ", "); - } - - p->skype_friends[0] = '\0'; - } - } - } else { - - ast_cli(fd, - "Skype not configured on the 'current' console, not importing from Skype client!\n"); - } - //} - /*******************************************************************************************/ - /*******************************************************************************************/ - } else { - ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn); - ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG, - fn); - return RESULT_FAILURE; - } - - fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - - return RESULT_SUCCESS; -} -#endif /* ASTERISK */ From gmaruzz at freeswitch.org Sat Feb 7 06:09:40 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sat, 07 Feb 2009 08:09:40 -0600 Subject: [Freeswitch-branches] [commit] r11679 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Sat Feb 7 08:09:40 2009 New Revision: 11679 Log: skypiax: * compile and works on Cygwin Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Sat Feb 7 08:09:40 2009 @@ -1285,6 +1285,7 @@ M_UINT("tcp_srv_port", tmp->tcp_srv_port) M_F("playback_boost", skypiax_store_boost(v->value, &tmp->playback_boost)) M_F("capture_boost", skypiax_store_boost(v->value, &tmp->capture_boost)) + M_STR("skype_user", tmp->skype_user) M_UINT("skypiax_dir_entry_extension_prefix", tmp->skypiax_dir_entry_extension_prefix) M_END(;); @@ -1404,6 +1405,7 @@ free(tmp); return NULL; } + /* res = pipe(tmp->SkypiaxHandles.fdesc); if (res) { ast_log(LOG_ERROR, "Unable to create skype pipe\n"); @@ -1415,6 +1417,7 @@ } fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); + */ tmp->skype_thread = AST_PTHREADT_NULL; if (tmp->skype) { @@ -1424,7 +1427,7 @@ (unsigned long) AST_PTHREADT_NULL); #ifdef __CYGWIN__ if (ast_pthread_create - (&tmp->skype_thread, NULL, do_skypeapi_thread, &tmp->SkypiaxHandles) < 0) { + (&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf Sat Feb 7 08:09:40 2009 @@ -53,6 +53,7 @@ X11_display=:101 tcp_cli_port=11234 tcp_srv_port=11235 +skype_user=gmaruzz2 ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels @@ -63,57 +64,58 @@ playback_boost=0 ; capture_boost=0 ; -[skypeclient2] -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; general settings, valid on all platforms -; -; -; Default language -; -language=en -; -; Default context (in extensions.conf, can be overridden with @context syntax) -; -context=default -; -; Default extension (in extensions.conf) where incoming calls land -; -extension=s -; -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; Debugging settings, valid globally for all interfaces on all platforms -; -; the debug values are global for all the interfaces. -; -; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax -; -; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch -; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages -; -; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all -; debug_all activate all possible debugging info -; -;debug_all=yes -debug_skype=yes -debug_pbx=yes -;debug_sound=yes -;debug_locks=yes -;debug_monitorlocks=yes - -skype=yes ; legacy setting, leave it to yes -X11_display=:102 -tcp_cli_port=11236 -tcp_srv_port=11237 -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels -; tweak it if you get horrible (or not hearable) sound -; -;boost can be positive or negative (-40 to +40) in db -;experiment to find which values are best for your computer -playback_boost=0 ; -capture_boost=0 ; - - +;;;[skypeclient2] +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; general settings, valid on all platforms +;;;; +;;;; +;;;; Default language +;;;; +;;;language=en +;;;; +;;;; Default context (in extensions.conf, can be overridden with @context syntax) +;;;; +;;;context=default +;;;; +;;;; Default extension (in extensions.conf) where incoming calls land +;;;; +;;;extension=s +;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; Debugging settings, valid globally for all interfaces on all platforms +;;;; +;;;; the debug values are global for all the interfaces. +;;;; +;;;; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax +;;;; +;;;; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch +;;;; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages +;;;; +;;;; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all +;;;; debug_all activate all possible debugging info +;;;; +;;;;debug_all=yes +;;;debug_skype=yes +;;;debug_pbx=yes +;;;;debug_sound=yes +;;;;debug_locks=yes +;;;;debug_monitorlocks=yes +;;; +;;;skype=yes ; legacy setting, leave it to yes +;;;X11_display=:102 +;;;tcp_cli_port=11236 +;;;tcp_srv_port=11237 +;;;skype_user=gmaruzz3 +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels +;;;; tweak it if you get horrible (or not hearable) sound +;;;; +;;;;boost can be positive or negative (-40 to +40) in db +;;;;experiment to find which values are best for your computer +;;;playback_boost=0 ; +;;;capture_boost=0 ; +;;; +;;; Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Sat Feb 7 08:09:40 2009 @@ -230,7 +230,7 @@ UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover; int api_connected; - switch_file_t *fdesc[2]; + int fdesc[2]; }; #endif //WIN32 @@ -329,10 +329,11 @@ void skypiax_skype_clean_disp(void *data); #endif /* WANT_SKYPE_X11 */ #ifdef __CYGWIN__ -int win32_Initialize_CreateWindowClass(void); -void win32_DeInitialize_DestroyWindowClass(void); -int win32_Initialize_CreateMainWindow(void); -void win32_DeInitialize_DestroyMainWindow(void); + +int win32_Initialize_CreateWindowClass(private_t * tech_pvt); +void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt); +int win32_Initialize_CreateMainWindow(private_t * tech_pvt); +void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt); #endif /* __CYGWIN__ */ /* CHAN_SKYPIAX.C */ Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sat Feb 7 08:09:40 2009 @@ -4,8 +4,8 @@ #define skypiax_sleep usleep #define tech_pvt p extern int skypiax_debug; -#define skypiax_file_write switch_file_write -#define skypiax_file_read switch_file_read +//#define skypiax_file_write switch_file_write +//#define skypiax_file_read switch_file_read extern char *skypiax_console_active; #else /* FREESWITCH */ #define skypiax_sleep switch_sleep @@ -157,7 +157,7 @@ howmany = len; -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany); #else /* WIN32 */ howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany); @@ -179,7 +179,7 @@ //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); if (len > 0) { if (len == SAMPLES_PER_FRAME * sizeof(short)) { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) unsigned int howmany; howmany = len; @@ -203,7 +203,7 @@ i++; } -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany); #else /* WIN32 */ howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany); @@ -233,7 +233,7 @@ skypiax_sleep(10000); } } -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size); kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); @@ -255,20 +255,20 @@ len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); #endif /* WIN32 */ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(fd); -#else +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(fd); +#else + close(fd); #endif if (exit) break; } DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(s); -#else +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(s); +#else + close(s); #endif if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -321,10 +321,10 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } -#ifndef WIN32 - close(s); +#if defined(WIN32) && !defined(__CYGWIN__) + closesocket(s); #else - closesocket(s); + close(s); #endif return NULL; } @@ -369,7 +369,7 @@ if (rt > 0) { if ((SAMPLERATE_SKYPIAX - 8000) == 0) { got = SAMPLES_PER_FRAME * sizeof(short); -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); #else /* WIN32 */ got = read(tech_pvt->audioskypepipe[0], cli_in, got); @@ -399,7 +399,7 @@ } } else if (SAMPLERATE_SKYPIAX == 16000) { got = SAMPLES_PER_FRAME * sizeof(short); -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); #else /* WIN32 */ got = read(tech_pvt->audioskypepipe[0], cli_in, got); @@ -436,19 +436,19 @@ } DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(fd); +#if defined(WIN32) && !defined(__CYGWIN__) + closesocket(s); #else - closesocket(fd); + close(fd); #endif break; } DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(s); -#else +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(s); +#else + close(s); #endif if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -459,7 +459,7 @@ int skypiax_skypeaudio_init(private_t * tech_pvt) { -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) switch_status_t rv; rv = switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], @@ -510,7 +510,7 @@ #endif /* WIN32 */ if (rt > 0) { samples = SAMPLES_PER_FRAME * sizeof(short); -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, &samples); #else /* WIN32 */ samples = read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); @@ -612,8 +612,13 @@ sizeof(msg_from_skype) - 2); howmany = strlen(msg_from_skype) + 1; +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, &howmany); - //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); + //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); +#else + howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); + //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); +#endif lReturnCode = 1; } break; @@ -758,9 +763,22 @@ /* destroy window class */ private_t *tech_pvt = obj; +#if defined(WIN32) && !defined(__CYGWIN__) + switch_status_t rv; switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); + rv = + switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], + skypiax_module_pool); +#else /* WIN32 */ + if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { + fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); + fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); + } +#endif /* WIN32 */ + + tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = @@ -1156,7 +1174,7 @@ if (rt > 0) { if (tech_pvt->SkypiaxHandles.fdesc[0]) { howmany = sizeof(read_from_pipe); -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, &howmany); #else /* WIN32 */ howmany = @@ -1256,7 +1274,7 @@ if (!strcasecmp(id, tech_pvt->skype_user)) { tech_pvt->SkypiaxHandles.api_connected = 1; - //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); + DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); } } From gmaruzz at freeswitch.org Sun Feb 8 03:43:41 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 05:43:41 -0600 Subject: [Freeswitch-branches] [commit] r11685 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Sun Feb 8 05:43:41 2009 New Revision: 11685 Log: skypiax: cleaning skypiax_protocol.c, will compile on win32? Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/Makefile Sun Feb 8 05:43:41 2009 @@ -49,7 +49,7 @@ CFLAGS+=-fPIC endif -SVNDEF := -D'SKYPIAX_SVN_VERSION="$(shell svnversion -n .)"' +SVNDEF := -D'SKYPIAX_SVN_VERSION="$(shell svnversion -n ..)"' CFLAGS += $(SVNDEF) Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 05:43:41 2009 @@ -4,15 +4,13 @@ #define skypiax_sleep usleep #define tech_pvt p extern int skypiax_debug; -//#define skypiax_file_write switch_file_write -//#define skypiax_file_read switch_file_read extern char *skypiax_console_active; #else /* FREESWITCH */ #define skypiax_sleep switch_sleep -extern switch_memory_pool_t *skypiax_module_pool; -extern switch_endpoint_interface_t *skypiax_endpoint_interface; #define skypiax_file_write switch_file_write #define skypiax_file_read switch_file_read +extern switch_memory_pool_t *skypiax_module_pool; +extern switch_endpoint_interface_t *skypiax_endpoint_interface; #endif /* ASTERISK */ extern int option_debug; @@ -29,23 +27,13 @@ { private_t *tech_pvt = obj; int s; -#ifdef WIN32 unsigned int len; unsigned int i; unsigned int a; - int sin_size; - unsigned int fd; - short srv_in[SAMPLES_PER_FRAME]; - short srv_out[SAMPLES_PER_FRAME / 2]; -#else - int len; - int i; - int a; unsigned int sin_size; - int fd; + unsigned int fd; short srv_in[SAMPLES_PER_FRAME]; short srv_out[SAMPLES_PER_FRAME / 2]; -#endif /* WIN32 */ struct sockaddr_in my_addr; struct sockaddr_in remote_addr; int exit = 0; @@ -89,12 +77,7 @@ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { -#ifdef WIN32 unsigned int fdselect; -#else - int received = 0; - int fdselect; -#endif /* WIN32 */ int rt; fd_set fs; struct timeval to; @@ -112,24 +95,11 @@ rt = select(fdselect + 1, &fs, NULL, NULL, &to); if (rt > 0) { -#ifdef WIN32 len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time -#else /* WIN32 */ - while (received < SAMPLES_PER_FRAME * sizeof(short)) { - len = recv(fd, srv_in + (received / sizeof(short)), (SAMPLES_PER_FRAME * sizeof(short)) - received, 0); //seems that Skype only sends 320 bytes at time - received += len; - if (len == 0) - break; - } - if (len) - len = received; -#endif /* WIN32 */ - if ((SAMPLERATE_SKYPIAX - 8000) == 0) { + if (SAMPLERATE_SKYPIAX == 8000) { - //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]); - //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); - if (len > 0) { + if (len == 320) { a = 0; for (i = 0; i < len / sizeof(short); i++) { srv_out[a] = srv_in[i]; @@ -175,19 +145,7 @@ } } else if (SAMPLERATE_SKYPIAX == 16000) { - //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]); - //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); - if (len > 0) { - if (len == SAMPLES_PER_FRAME * sizeof(short)) { -#if defined(WIN32) && !defined(__CYGWIN__) - unsigned int howmany; - - howmany = len; - skypiax_file_write(tech_pvt->audiopipe[1], srv_in, &howmany); -#else /* WIN32 */ - len = write(tech_pvt->audiopipe[1], srv_in, len); -#endif /* WIN32 */ - } else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) { + if (len == 320) { if (!tech_pvt->audiobuf_is_loaded) { for (i = 0; i < (len / sizeof(short)); i++) { tech_pvt->audiobuf[i] = srv_in[i]; @@ -210,11 +168,6 @@ #endif /* WIN32 */ tech_pvt->audiobuf_is_loaded = 0; } - - } else { - ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len); - } - } else if (len == 0) { DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); skypiax_sleep(1000); From gmaruzz at freeswitch.org Sun Feb 8 04:38:59 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 06:38:59 -0600 Subject: [Freeswitch-branches] [commit] r11686 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 06:38:59 2009 New Revision: 11686 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 06:38:59 2009 @@ -7,7 +7,7 @@ extern char *skypiax_console_active; #else /* FREESWITCH */ #define skypiax_sleep switch_sleep -#define skypiax_file_write switch_file_write +//#define skypiax_file_write switch_file_write #define skypiax_file_read switch_file_read extern switch_memory_pool_t *skypiax_module_pool; extern switch_endpoint_interface_t *skypiax_endpoint_interface; @@ -23,6 +23,18 @@ #endif /* WIN32 */ /*************************************/ +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_file_write(switch_file_t *pipe, short *buf, int howmany){ + switch_file_write(pipe, buf, &howmany); + return howmany; +} +#else /* WIN32 */ +int skypiax_file_write(int pipe, short *buf, int howmany){ + howmany = write(pipe, buf, howmany); + return howmany; +} +#endif /* WIN32 */ + void * skypiax_do_tcp_srv_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -127,11 +139,7 @@ howmany = len; -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany); -#else /* WIN32 */ - howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany); -#endif /* WIN32 */ + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); tech_pvt->audiobuf_is_loaded = 0; } @@ -161,11 +169,7 @@ i++; } -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany); -#else /* WIN32 */ - howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany); -#endif /* WIN32 */ + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); tech_pvt->audiobuf_is_loaded = 0; } } else if (len == 0) { From gmaruzz at freeswitch.org Sun Feb 8 05:01:09 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 07:01:09 -0600 Subject: [Freeswitch-branches] [commit] r11687 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 07:01:09 2009 New Revision: 11687 Log: skypiax: cleaning skypiax_protocol.c, will it works on linux? Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 07:01:09 2009 @@ -25,7 +25,14 @@ #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_file_write(switch_file_t *pipe, short *buf, int howmany){ - switch_file_write(pipe, buf, &howmany); + switch_size_t quantity; + + quantity = howmany; + + switch_file_write(pipe, buf, &quantity); + + howmany = quantity; + return howmany; } #else /* WIN32 */ @@ -42,7 +49,11 @@ unsigned int len; unsigned int i; unsigned int a; +#if defined(WIN32) && !defined(__CYGWIN__) + int sin_size; +#else /* WIN32 */ unsigned int sin_size; +#endif /* WIN32 */ unsigned int fd; short srv_in[SAMPLES_PER_FRAME]; short srv_out[SAMPLES_PER_FRAME / 2]; @@ -190,6 +201,7 @@ skypiax_sleep(10000); } } +#if 0 #if defined(WIN32) && !defined(__CYGWIN__) kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size); @@ -211,6 +223,20 @@ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); #endif /* WIN32 */ +#endif + + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); + + + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); #if defined(WIN32) && !defined(__CYGWIN__) closesocket(fd); @@ -569,13 +595,13 @@ sizeof(msg_from_skype) - 2); howmany = strlen(msg_from_skype) + 1; -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, &howmany); +//#if defined(WIN32) && !defined(__CYGWIN__) + howmany = skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *)msg_from_skype, howmany); //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); -#else - howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); +//#else + //howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); -#endif +//#endif lReturnCode = 1; } break; From gmaruzz at freeswitch.org Sun Feb 8 05:49:11 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 07:49:11 -0600 Subject: [Freeswitch-branches] [commit] r11688 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 07:49:11 2009 New Revision: 11688 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 07:49:11 2009 @@ -116,10 +116,99 @@ to.tv_sec = 0; rt = select(fdselect + 1, &fs, NULL, NULL, &to); +#ifndef NOTDEF if (rt > 0) { len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time + if (len == 320) { + + if (SAMPLERATE_SKYPIAX == 8000) { + + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + srv_out[a] = srv_in[i]; + i++; + a++; + } + + if (!tech_pvt->audiobuf_is_loaded) { + for (i = 0; i < (len / sizeof(short)) / 2; i++) { + tech_pvt->audiobuf[i] = srv_out[i]; + } + tech_pvt->audiobuf_is_loaded = 1; + } else { + unsigned int howmany; + + howmany = len / 2 / 2; + for (i = 0; i < howmany; i++) + totalbuf[i] = tech_pvt->audiobuf[i]; + + howmany = len / 2 / 2; + for (a = 0; a < howmany; a++) { + totalbuf[i] = srv_out[a]; + i++; + } + + howmany = len; + + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); + tech_pvt->audiobuf_is_loaded = 0; + } + + } else if (SAMPLERATE_SKYPIAX == 16000) { + + if (!tech_pvt->audiobuf_is_loaded) { + for (i = 0; i < (len / sizeof(short)); i++) { + tech_pvt->audiobuf[i] = srv_in[i]; + } + tech_pvt->audiobuf_is_loaded = 1; + } else { + unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short); + + for (i = 0; i < (len / sizeof(short)); i++) + totalbuf[i] = tech_pvt->audiobuf[i]; + for (a = 0; a < (len / sizeof(short)); a++) { + totalbuf[i] = srv_in[a]; + i++; + } + + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); + tech_pvt->audiobuf_is_loaded = 0; + } + + } else { + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + } + + } else if (len == 0) { + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + skypiax_sleep(1000); + } else { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + exit = 1; + break; + } + + + + + + + + } else { + if (rt) + ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); + skypiax_sleep(10000); + } +#endif // NOTDEF + +#ifdef NOTDEF + if (rt > 0) { + + len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time + + if (SAMPLERATE_SKYPIAX == 8000) { if (len == 320) { @@ -200,30 +289,8 @@ ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); skypiax_sleep(10000); } +#endif // NOTDEF } -#if 0 -#if defined(WIN32) && !defined(__CYGWIN__) - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size); -#else /* WIN32 */ - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); -#endif /* WIN32 */ -#endif kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); @@ -235,8 +302,6 @@ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); #if defined(WIN32) && !defined(__CYGWIN__) closesocket(fd); From gmaruzz at freeswitch.org Sun Feb 8 06:02:51 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 08:02:51 -0600 Subject: [Freeswitch-branches] [commit] r11689 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 08:02:51 2009 New Revision: 11689 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 08:02:51 2009 @@ -23,33 +23,35 @@ #endif /* WIN32 */ /*************************************/ -#if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_file_write(switch_file_t *pipe, short *buf, int howmany){ - switch_size_t quantity; +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_file_write(switch_file_t * pipe, short *buf, int howmany) +{ + switch_size_t quantity; - quantity = howmany; + quantity = howmany; - switch_file_write(pipe, buf, &quantity); + switch_file_write(pipe, buf, &quantity); - howmany = quantity; + howmany = quantity; - return howmany; + return howmany; } #else /* WIN32 */ -int skypiax_file_write(int pipe, short *buf, int howmany){ - howmany = write(pipe, buf, howmany); - return howmany; +int skypiax_file_write(int pipe, short *buf, int howmany) +{ + howmany = write(pipe, buf, howmany); + return howmany; } #endif /* WIN32 */ -void * skypiax_do_tcp_srv_thread_func(void *obj) +void *skypiax_do_tcp_srv_thread_func(void *obj) { private_t *tech_pvt = obj; int s; unsigned int len; unsigned int i; unsigned int a; -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) int sin_size; #else /* WIN32 */ unsigned int sin_size; @@ -116,14 +118,14 @@ to.tv_sec = 0; rt = select(fdselect + 1, &fs, NULL, NULL, &to); -#ifndef NOTDEF if (rt > 0) { len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time - if (len == 320) { + if (len == 320) { + unsigned int howmany; - if (SAMPLERATE_SKYPIAX == 8000) { + if (SAMPLERATE_SKYPIAX == 8000) { a = 0; for (i = 0; i < len / sizeof(short); i++) { @@ -138,7 +140,6 @@ } tech_pvt->audiobuf_is_loaded = 1; } else { - unsigned int howmany; howmany = len / 2 / 2; for (i = 0; i < howmany; i++) @@ -156,140 +157,46 @@ tech_pvt->audiobuf_is_loaded = 0; } - } else if (SAMPLERATE_SKYPIAX == 16000) { - - if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)); i++) { - tech_pvt->audiobuf[i] = srv_in[i]; - } - tech_pvt->audiobuf_is_loaded = 1; - } else { - unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short); - - for (i = 0; i < (len / sizeof(short)); i++) - totalbuf[i] = tech_pvt->audiobuf[i]; - for (a = 0; a < (len / sizeof(short)); a++) { - totalbuf[i] = srv_in[a]; - i++; - } - - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); - tech_pvt->audiobuf_is_loaded = 0; - } - - } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); - } - - } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - skypiax_sleep(1000); - } else { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; - } - - - - - - - - } else { - if (rt) - ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); - skypiax_sleep(10000); - } -#endif // NOTDEF - -#ifdef NOTDEF - if (rt > 0) { - - len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time - - - if (SAMPLERATE_SKYPIAX == 8000) { - - if (len == 320) { - a = 0; - for (i = 0; i < len / sizeof(short); i++) { - srv_out[a] = srv_in[i]; - i++; - a++; - } + } else if (SAMPLERATE_SKYPIAX == 16000) { if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)) / 2; i++) { - tech_pvt->audiobuf[i] = srv_out[i]; + for (i = 0; i < (len / sizeof(short)); i++) { + tech_pvt->audiobuf[i] = srv_in[i]; } tech_pvt->audiobuf_is_loaded = 1; } else { - unsigned int howmany; + howmany = SAMPLES_PER_FRAME * sizeof(short); - howmany = len / 2 / 2; - for (i = 0; i < howmany; i++) + for (i = 0; i < (len / sizeof(short)); i++) totalbuf[i] = tech_pvt->audiobuf[i]; - - howmany = len / 2 / 2; - for (a = 0; a < howmany; a++) { - totalbuf[i] = srv_out[a]; + for (a = 0; a < (len / sizeof(short)); a++) { + totalbuf[i] = srv_in[a]; i++; } - howmany = len; - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); tech_pvt->audiobuf_is_loaded = 0; } - } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - skypiax_sleep(1000); } else { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; - } - } else if (SAMPLERATE_SKYPIAX == 16000) { - - if (len == 320) { - if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)); i++) { - tech_pvt->audiobuf[i] = srv_in[i]; - } - tech_pvt->audiobuf_is_loaded = 1; - } else { - unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short); - - for (i = 0; i < (len / sizeof(short)); i++) - totalbuf[i] = tech_pvt->audiobuf[i]; - for (a = 0; a < (len / sizeof(short)); a++) { - totalbuf[i] = srv_in[a]; - i++; - } - - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); - tech_pvt->audiobuf_is_loaded = 0; - } - } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - skypiax_sleep(1000); - } else { - ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } + } else if (len == 0) { + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + skypiax_sleep(1000); } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + exit = 1; + break; } + } else { if (rt) ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); skypiax_sleep(10000); } -#endif // NOTDEF + } kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); @@ -303,7 +210,7 @@ len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(fd); #else close(fd); @@ -313,7 +220,7 @@ } DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(s); #else close(s); @@ -323,7 +230,7 @@ } return NULL; } -void * skypiax_do_tcp_cli_thread_func(void *obj) +void *skypiax_do_tcp_cli_thread_func(void *obj) { private_t *tech_pvt = obj; int s; @@ -369,8 +276,8 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); +#if defined(WIN32) && !defined(__CYGWIN__) + closesocket(s); #else close(s); #endif @@ -417,7 +324,7 @@ if (rt > 0) { if ((SAMPLERATE_SKYPIAX - 8000) == 0) { got = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); #else /* WIN32 */ got = read(tech_pvt->audioskypepipe[0], cli_in, got); @@ -447,7 +354,7 @@ } } else if (SAMPLERATE_SKYPIAX == 16000) { got = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); #else /* WIN32 */ got = read(tech_pvt->audioskypepipe[0], cli_in, got); @@ -484,8 +391,8 @@ } DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); +#if defined(WIN32) && !defined(__CYGWIN__) + closesocket(s); #else close(fd); #endif @@ -493,7 +400,7 @@ } DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) closesocket(s); #else close(s); @@ -507,7 +414,7 @@ int skypiax_skypeaudio_init(private_t * tech_pvt) { -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) switch_status_t rv; rv = switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], @@ -558,7 +465,7 @@ #endif /* WIN32 */ if (rt > 0) { samples = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, &samples); #else /* WIN32 */ samples = read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); @@ -661,10 +568,12 @@ howmany = strlen(msg_from_skype) + 1; //#if defined(WIN32) && !defined(__CYGWIN__) - howmany = skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *)msg_from_skype, howmany); + howmany = + skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, + howmany); //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); //#else - //howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); + //howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); //#endif lReturnCode = 1; @@ -799,7 +708,7 @@ DWORD win32_dwThreadId; -void * skypiax_do_skypeapi_thread_func(void *obj) +void *skypiax_do_skypeapi_thread_func(void *obj) { /* create window class */ /* create dummy/hidden window for processing messages */ @@ -811,14 +720,14 @@ /* destroy window class */ private_t *tech_pvt = obj; -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) switch_status_t rv; switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); rv = - switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], &tech_pvt->SkypiaxHandles.fdesc[1], - skypiax_module_pool); + switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], + &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); #else /* WIN32 */ if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); @@ -826,7 +735,6 @@ } #endif /* WIN32 */ - tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = @@ -991,7 +899,7 @@ skypiax_sleep(1000); } -void * skypiax_do_skypeapi_thread_func(void *obj) +void *skypiax_do_skypeapi_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -1003,14 +911,14 @@ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - if(!strlen(tech_pvt->X11_display)) - strcpy(tech_pvt->X11_display, getenv("DISPLAY")); + if (!strlen(tech_pvt->X11_display)) + strcpy(tech_pvt->X11_display, getenv("DISPLAY")); - if(!tech_pvt->tcp_srv_port) - tech_pvt->tcp_srv_port = 10160; + if (!tech_pvt->tcp_srv_port) + tech_pvt->tcp_srv_port = 10160; - if(!tech_pvt->tcp_cli_port) - tech_pvt->tcp_cli_port = 10161; + if (!tech_pvt->tcp_cli_port) + tech_pvt->tcp_cli_port = 10161; if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); @@ -1021,7 +929,7 @@ if (!disp) { ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG, tech_pvt->X11_display); - running=0; + running = 0; return NULL; } else { DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display); @@ -1052,7 +960,7 @@ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", SKYPIAX_P_LOG); DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running=0; + running = 0; return NULL; } @@ -1062,7 +970,7 @@ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", SKYPIAX_P_LOG); DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running=0; + running = 0; return NULL; } @@ -1110,11 +1018,11 @@ ERRORA ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", SKYPIAX_P_LOG); - running=0; + running = 0; return NULL; } DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running=0; + running = 0; return NULL; } @@ -1222,7 +1130,7 @@ if (rt > 0) { if (tech_pvt->SkypiaxHandles.fdesc[0]) { howmany = sizeof(read_from_pipe); -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) skypiax_file_read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, &howmany); #else /* WIN32 */ howmany = @@ -1322,7 +1230,9 @@ if (!strcasecmp(id, tech_pvt->skype_user)) { tech_pvt->SkypiaxHandles.api_connected = 1; - DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); + DEBUGA_SKYPE + ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); } } @@ -1438,11 +1348,11 @@ tech_pvt->interface_state = SKYPIAX_STATE_PRERING; } - if (!strcasecmp(prop, "DTMF")) { + if (!strcasecmp(prop, "DTMF")) { DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); - dtmf_received(tech_pvt, value); + dtmf_received(tech_pvt, value); } if (!strcasecmp(prop, "FAILUREREASON")) { @@ -1596,7 +1506,7 @@ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; + char msg_to_skype[1024]; tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_UP; @@ -1607,29 +1517,29 @@ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG, id); - start_audio_threads(tech_pvt); + start_audio_threads(tech_pvt); + + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, + tech_pvt->tcp_srv_port); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(100000); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, - tech_pvt->tcp_srv_port); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(100000); - tech_pvt->skype_callflow = SKYPIAX_STATE_UP; if (!strlen(tech_pvt->session_uuid_str)) { DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); - new_inbound_channel(tech_pvt); - } else { + new_inbound_channel(tech_pvt); + } else { DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); + outbound_channel_answered(tech_pvt); } } else { @@ -1700,4 +1610,3 @@ //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); return 0; } - From gmaruzz at freeswitch.org Sun Feb 8 06:28:45 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 08:28:45 -0600 Subject: [Freeswitch-branches] [commit] r11690 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 08:28:45 2009 New Revision: 11690 Log: skypiax: checking sizes on win Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 08:28:45 2009 @@ -126,8 +126,10 @@ unsigned int howmany; if (SAMPLERATE_SKYPIAX == 8000) { - + NOTICA("sizeof(short)=%d, \tSAMPLES_PER_FRAME=%d, \tSAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short)); + NOTICA("sizeof(short)=%d, \tlen=%d, \tlen/sizeof(short)/2=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short)/2); a = 0; + /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ for (i = 0; i < len / sizeof(short); i++) { srv_out[a] = srv_in[i]; i++; @@ -141,11 +143,11 @@ tech_pvt->audiobuf_is_loaded = 1; } else { - howmany = len / 2 / 2; - for (i = 0; i < howmany; i++) + howmany = len / sizeof(short) / 2; + for (i = 0; i < howmany; i++){ totalbuf[i] = tech_pvt->audiobuf[i]; + } - howmany = len / 2 / 2; for (a = 0; a < howmany; a++) { totalbuf[i] = srv_out[a]; i++; @@ -158,6 +160,8 @@ } } else if (SAMPLERATE_SKYPIAX == 16000) { + NOTICA("sizeof(short)=%d, SAMPLES_PER_FRAME=%d, SAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short)); + NOTICA("sizeof(short)=%d, len=%d, len/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short)); if (!tech_pvt->audiobuf_is_loaded) { for (i = 0; i < (len / sizeof(short)); i++) { @@ -167,8 +171,9 @@ } else { howmany = SAMPLES_PER_FRAME * sizeof(short); - for (i = 0; i < (len / sizeof(short)); i++) + for (i = 0; i < (len / sizeof(short)); i++){ totalbuf[i] = tech_pvt->audiobuf[i]; + } for (a = 0; a < (len / sizeof(short)); a++) { totalbuf[i] = srv_in[a]; i++; From gmaruzz at freeswitch.org Sun Feb 8 07:09:15 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 09:09:15 -0600 Subject: [Freeswitch-branches] [commit] r11691 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 09:09:14 2009 New Revision: 11691 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 09:09:14 2009 @@ -126,8 +126,6 @@ unsigned int howmany; if (SAMPLERATE_SKYPIAX == 8000) { - NOTICA("sizeof(short)=%d, \tSAMPLES_PER_FRAME=%d, \tSAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short)); - NOTICA("sizeof(short)=%d, \tlen=%d, \tlen/sizeof(short)/2=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short)/2); a = 0; /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ for (i = 0; i < len / sizeof(short); i++) { @@ -135,51 +133,53 @@ i++; a++; } - + /* if not yet done, let's store half incoming frame */ if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)) / 2; i++) { + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { tech_pvt->audiobuf[i] = srv_out[i]; } tech_pvt->audiobuf_is_loaded = 1; } else { - - howmany = len / sizeof(short) / 2; - for (i = 0; i < howmany; i++){ + /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++){ totalbuf[i] = tech_pvt->audiobuf[i]; } - - for (a = 0; a < howmany; a++) { + for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) { totalbuf[i] = srv_out[a]; i++; } - - howmany = len; - - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); + /* send the complete frame through the pipe to our code waiting for incoming audio */ + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short)); + if(howmany != SAMPLES_PER_FRAME * sizeof(short)){ + ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short)); + } + /* done with the stored half frame */ tech_pvt->audiobuf_is_loaded = 0; } } else if (SAMPLERATE_SKYPIAX == 16000) { - NOTICA("sizeof(short)=%d, SAMPLES_PER_FRAME=%d, SAMPLES_PER_FRAME/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), SAMPLES_PER_FRAME, SAMPLES_PER_FRAME/sizeof(short)); - NOTICA("sizeof(short)=%d, len=%d, len/sizeof(short)=%d\n", SKYPIAX_P_LOG, sizeof(short), len, len/sizeof(short)); - + /* if not yet done, let's store half incoming frame */ if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)); i++) { + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { tech_pvt->audiobuf[i] = srv_in[i]; } tech_pvt->audiobuf_is_loaded = 1; } else { - howmany = SAMPLES_PER_FRAME * sizeof(short); - - for (i = 0; i < (len / sizeof(short)); i++){ + /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ + for (i = 0; i < (SAMPLES_PER_FRAME / 2); i++){ totalbuf[i] = tech_pvt->audiobuf[i]; } - for (a = 0; a < (len / sizeof(short)); a++) { + for (a = 0; a < (SAMPLES_PER_FRAME / 2); a++) { totalbuf[i] = srv_in[a]; i++; } - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany); + /* send the complete frame through the pipe to our code waiting for incoming audio */ + howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short)); + if(howmany != SAMPLES_PER_FRAME * sizeof(short)){ + ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short)); + } + /* done with the stored half frame */ tech_pvt->audiobuf_is_loaded = 0; } From gmaruzz at freeswitch.org Sun Feb 8 08:05:32 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 10:05:32 -0600 Subject: [Freeswitch-branches] [commit] r11692 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 10:05:32 2009 New Revision: 11692 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 10:05:32 2009 @@ -43,6 +43,26 @@ return howmany; } #endif /* WIN32 */ +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_close_socket(unsigned int fd) +{ + int res; + + res = closesocket(fd); + + return res; +} +#else /* WIN32 */ +int skypiax_close_socket(unsigned int fd) +{ + int res; + + res = close(fd); + + return res; +} +#endif /* WIN32 */ + void *skypiax_do_tcp_srv_thread_func(void *obj) { @@ -125,15 +145,23 @@ if (len == 320) { unsigned int howmany; - if (SAMPLERATE_SKYPIAX == 8000) { - a = 0; - /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ - for (i = 0; i < len / sizeof(short); i++) { - srv_out[a] = srv_in[i]; - i++; - a++; - } - /* if not yet done, let's store half incoming frame */ + if (SAMPLERATE_SKYPIAX == 8000) { + /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + srv_out[a] = srv_in[i]; + i++; + a++; + } + } else if (SAMPLERATE_SKYPIAX == 16000) { + /* we're NOT downsampling from 16khz to 8khz, srv_out will contain ALL samples from srv_in */ + for (i = 0; i < len / sizeof(short); i++) { + srv_out[i] = srv_in[i]; + } + } else { + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + } + /* if not yet done, let's store the half incoming frame */ if (!tech_pvt->audiobuf_is_loaded) { for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { tech_pvt->audiobuf[i] = srv_out[i]; @@ -157,36 +185,6 @@ tech_pvt->audiobuf_is_loaded = 0; } - } else if (SAMPLERATE_SKYPIAX == 16000) { - /* if not yet done, let's store half incoming frame */ - if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { - tech_pvt->audiobuf[i] = srv_in[i]; - } - tech_pvt->audiobuf_is_loaded = 1; - } else { - /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ - for (i = 0; i < (SAMPLES_PER_FRAME / 2); i++){ - totalbuf[i] = tech_pvt->audiobuf[i]; - } - for (a = 0; a < (SAMPLES_PER_FRAME / 2); a++) { - totalbuf[i] = srv_in[a]; - i++; - } - - /* send the complete frame through the pipe to our code waiting for incoming audio */ - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short)); - if(howmany != SAMPLES_PER_FRAME * sizeof(short)){ - ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short)); - } - /* done with the stored half frame */ - tech_pvt->audiobuf_is_loaded = 0; - } - - } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); - } - } else if (len == 0) { DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); skypiax_sleep(1000); @@ -215,21 +213,13 @@ len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(fd); -#else - close(fd); -#endif + skypiax_close_socket(fd); if (exit) break; } DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); -#else - close(s); -#endif + skypiax_close_socket(s); if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -281,11 +271,7 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); -#else - close(s); -#endif + skypiax_close_socket(s); return NULL; } DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); @@ -396,20 +382,12 @@ } DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); -#else - close(fd); -#endif + skypiax_close_socket(s); break; } DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); -#if defined(WIN32) && !defined(__CYGWIN__) - closesocket(s); -#else - close(s); -#endif + skypiax_close_socket(s); if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } From gmaruzz at freeswitch.org Sun Feb 8 08:14:39 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 10:14:39 -0600 Subject: [Freeswitch-branches] [commit] r11693 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 10:14:38 2009 New Revision: 11693 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 10:14:38 2009 @@ -46,24 +46,23 @@ #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_close_socket(unsigned int fd) { - int res; + int res; - res = closesocket(fd); + res = closesocket(fd); return res; } #else /* WIN32 */ int skypiax_close_socket(unsigned int fd) { - int res; + int res; - res = close(fd); + res = close(fd); return res; } #endif /* WIN32 */ - void *skypiax_do_tcp_srv_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -145,45 +144,48 @@ if (len == 320) { unsigned int howmany; - if (SAMPLERATE_SKYPIAX == 8000) { - /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ - a = 0; - for (i = 0; i < len / sizeof(short); i++) { - srv_out[a] = srv_in[i]; - i++; - a++; - } - } else if (SAMPLERATE_SKYPIAX == 16000) { - /* we're NOT downsampling from 16khz to 8khz, srv_out will contain ALL samples from srv_in */ - for (i = 0; i < len / sizeof(short); i++) { - srv_out[i] = srv_in[i]; - } - } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); - } - /* if not yet done, let's store the half incoming frame */ - if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { - tech_pvt->audiobuf[i] = srv_out[i]; - } - tech_pvt->audiobuf_is_loaded = 1; - } else { - /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ - for (i = 0; i < SAMPLES_PER_FRAME / 2; i++){ - totalbuf[i] = tech_pvt->audiobuf[i]; - } - for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) { - totalbuf[i] = srv_out[a]; - i++; - } - /* send the complete frame through the pipe to our code waiting for incoming audio */ - howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short)); - if(howmany != SAMPLES_PER_FRAME * sizeof(short)){ - ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, SAMPLES_PER_FRAME * sizeof(short)); - } - /* done with the stored half frame */ - tech_pvt->audiobuf_is_loaded = 0; + if (SAMPLERATE_SKYPIAX == 8000) { + /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + srv_out[a] = srv_in[i]; + i++; + a++; } + } else if (SAMPLERATE_SKYPIAX == 16000) { + /* we're NOT downsampling from 16khz to 8khz, srv_out will contain ALL samples from srv_in */ + for (i = 0; i < len / sizeof(short); i++) { + srv_out[i] = srv_in[i]; + } + } else { + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + } + /* if not yet done, let's store the half incoming frame */ + if (!tech_pvt->audiobuf_is_loaded) { + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { + tech_pvt->audiobuf[i] = srv_out[i]; + } + tech_pvt->audiobuf_is_loaded = 1; + } else { + /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { + totalbuf[i] = tech_pvt->audiobuf[i]; + } + for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) { + totalbuf[i] = srv_out[a]; + i++; + } + /* send the complete frame through the pipe to our code waiting for incoming audio */ + howmany = + skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, + SAMPLES_PER_FRAME * sizeof(short)); + if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { + ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, + SAMPLES_PER_FRAME * sizeof(short)); + } + /* done with the stored half frame */ + tech_pvt->audiobuf_is_loaded = 0; + } } else if (len == 0) { DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Sun Feb 8 09:10:44 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 11:10:44 -0600 Subject: [Freeswitch-branches] [commit] r11694 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 11:10:44 2009 New Revision: 11694 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 11:10:44 2009 @@ -7,8 +7,8 @@ extern char *skypiax_console_active; #else /* FREESWITCH */ #define skypiax_sleep switch_sleep -//#define skypiax_file_write switch_file_write -#define skypiax_file_read switch_file_read +//#define skypiax_pipe_write switch_file_write +//#define skypiax_pipe_read switch_file_read extern switch_memory_pool_t *skypiax_module_pool; extern switch_endpoint_interface_t *skypiax_endpoint_interface; #endif /* ASTERISK */ @@ -23,8 +23,31 @@ #endif /* WIN32 */ /*************************************/ + +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany) +{ + switch_size_t quantity; + + quantity = howmany; + + switch_file_read(pipe, buf, &quantity); + + howmany = quantity; + + return howmany; +} +#else /* WIN32 */ +int skypiax_pipe_read(int pipe, short *buf, int howmany) +{ + howmany = read(pipe, buf, howmany); + return howmany; +} +#endif /* WIN32 */ + + #if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_file_write(switch_file_t * pipe, short *buf, int howmany) +int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany) { switch_size_t quantity; @@ -37,12 +60,14 @@ return howmany; } #else /* WIN32 */ -int skypiax_file_write(int pipe, short *buf, int howmany) +int skypiax_pipe_write(int pipe, short *buf, int howmany) { howmany = write(pipe, buf, howmany); return howmany; } #endif /* WIN32 */ + + #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_close_socket(unsigned int fd) { @@ -153,7 +178,7 @@ a++; } } else if (SAMPLERATE_SKYPIAX == 16000) { - /* we're NOT downsampling from 16khz to 8khz, srv_out will contain ALL samples from srv_in */ + /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */ for (i = 0; i < len / sizeof(short); i++) { srv_out[i] = srv_in[i]; } @@ -177,7 +202,7 @@ } /* send the complete frame through the pipe to our code waiting for incoming audio */ howmany = - skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, + skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short)); if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, @@ -204,17 +229,18 @@ } + /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); + len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); tech_pvt->interface_state = SKYPIAX_STATE_DOWN; kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); + len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(fd); if (exit) break; @@ -227,6 +253,8 @@ } return NULL; } + + void *skypiax_do_tcp_cli_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -317,11 +345,7 @@ if (rt > 0) { if ((SAMPLERATE_SKYPIAX - 8000) == 0) { got = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); -#else /* WIN32 */ - got = read(tech_pvt->audioskypepipe[0], cli_in, got); -#endif /* WIN32 */ + got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, got); if (got > 0) { a = 0; @@ -347,11 +371,7 @@ } } else if (SAMPLERATE_SKYPIAX == 16000) { got = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_read(tech_pvt->audioskypepipe[0], cli_in, &got); -#else /* WIN32 */ - got = read(tech_pvt->audioskypepipe[0], cli_in, got); -#endif /* WIN32 */ + got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, got); if (got > 0) { if (got != SAMPLES_PER_FRAME * sizeof(short)) @@ -450,11 +470,7 @@ #endif /* WIN32 */ if (rt > 0) { samples = SAMPLES_PER_FRAME * sizeof(short); -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, &samples); -#else /* WIN32 */ - samples = read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); -#endif /* WIN32 */ + samples = skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]); //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); @@ -554,7 +570,7 @@ howmany = strlen(msg_from_skype) + 1; //#if defined(WIN32) && !defined(__CYGWIN__) howmany = - skypiax_file_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, + skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, howmany); //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); //#else @@ -1115,12 +1131,7 @@ if (rt > 0) { if (tech_pvt->SkypiaxHandles.fdesc[0]) { howmany = sizeof(read_from_pipe); -#if defined(WIN32) && !defined(__CYGWIN__) - skypiax_file_read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, &howmany); -#else /* WIN32 */ - howmany = - read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, sizeof(read_from_pipe)); -#endif /* WIN32 */ + howmany = skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *)read_from_pipe, howmany); a = 0; for (i = 0; i < howmany; i++) { From gmaruzz at freeswitch.org Sun Feb 8 10:51:05 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 12:51:05 -0600 Subject: [Freeswitch-branches] [commit] r11695 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 12:51:05 2009 New Revision: 11695 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 12:51:05 2009 @@ -213,7 +213,7 @@ } } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); skypiax_sleep(1000); } else { ERRORA("len=%d\n", SKYPIAX_P_LOG, len); @@ -246,7 +246,7 @@ break; } - DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(s); if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -262,22 +262,16 @@ struct sockaddr_in my_addr; struct sockaddr_in remote_addr; unsigned int got; -#ifdef WIN32 unsigned int len; unsigned int i; unsigned int a; - int sin_size; unsigned int fd; short cli_out[SAMPLES_PER_FRAME * 2]; short cli_in[SAMPLES_PER_FRAME]; +#ifdef WIN32 + int sin_size; #else - int len; - int i; - int a; unsigned int sin_size; - int fd; - short cli_out[SAMPLES_PER_FRAME * 2]; - short cli_in[SAMPLES_PER_FRAME]; #endif /* WIN32 */ if (option_debug > 100) { @@ -286,7 +280,7 @@ memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(tech_pvt->tcp_cli_port); //FIXME configurable! + my_addr.sin_port = htons(tech_pvt->tcp_cli_port); if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); @@ -343,11 +337,18 @@ rt = select(fdselect + 1, &fs, NULL, NULL, &to); #endif /* WIN32 */ if (rt > 0) { - if ((SAMPLERATE_SKYPIAX - 8000) == 0) { - got = SAMPLES_PER_FRAME * sizeof(short); - got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, got); - if (got > 0) { + /* read from the pipe the audio frame we are supposed to send out */ + got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, SAMPLES_PER_FRAME * sizeof(short)); + if (got != SAMPLES_PER_FRAME * sizeof(short)) { + ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + SAMPLES_PER_FRAME * sizeof(short)); + } + + if (got == SAMPLES_PER_FRAME * sizeof(short)) { + if (SAMPLERATE_SKYPIAX == 8000) { + + /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */ a = 0; for (i = 0; i < got / sizeof(short); i++) { cli_out[a] = cli_in[i]; @@ -355,60 +356,50 @@ cli_out[a] = cli_in[i]; a++; } - -#ifdef WIN32 - len = send(fd, (char *) cli_out, got * 2, 0); -#else /* WIN32 */ - len = send(fd, cli_out, got * 2, 0); -#endif /* WIN32 */ - if (len == 0) { - ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); - break; + got = got * 2; + } else if (SAMPLERATE_SKYPIAX == 16000) { + /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */ + for (i = 0; i < got / sizeof(short); i++) { + cli_out[i] = cli_in[i]; } } else { - skypiax_sleep(1000); - ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got); + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } - } else if (SAMPLERATE_SKYPIAX == 16000) { - got = SAMPLES_PER_FRAME * sizeof(short); - got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, got); - - if (got > 0) { - if (got != SAMPLES_PER_FRAME * sizeof(short)) - ERRORA("CLI PIPE read %d\n", SKYPIAX_P_LOG, got); + /* send the 16khz frame to the Skype client waiting for incoming audio */ #ifdef WIN32 - len = send(fd, (char *) cli_in, got, 0); + len = send(fd, (char *) cli_out, got, 0); #else /* WIN32 */ - len = send(fd, cli_in, got, 0); -#endif /* WIN32 */ - - if (len != got && len != -1) - DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len); - - if (len == 0) { - ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); + len = send(fd, cli_out, got, 0); +#endif /* WIN32 */ + + if (len == -1) { break; - } - } else { - skypiax_sleep(1000); - ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got); - } + } else if (len != got){ + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + skypiax_sleep(1000); + break; } + } else { + + ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, SAMPLES_PER_FRAME * sizeof(short)); + skypiax_sleep(10000); + + } } else { - skypiax_sleep(1000); if (rt) - ERRORA("select give us: %u\n", SKYPIAX_P_LOG, rt); + ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); + skypiax_sleep(10000); } - } - DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); - skypiax_close_socket(s); + } + DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG); + skypiax_close_socket(fd); break; } - DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(s); if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -441,9 +432,6 @@ /* the pipe is the audio fd for asterisk to poll on during a call */ tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } From gmaruzz at freeswitch.org Sun Feb 8 11:01:28 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sun, 08 Feb 2009 13:01:28 -0600 Subject: [Freeswitch-branches] [commit] r11696 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Sun Feb 8 13:01:28 2009 New Revision: 11696 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Sun Feb 8 13:01:28 2009 @@ -23,7 +23,6 @@ #endif /* WIN32 */ /*************************************/ - #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany) { @@ -45,7 +44,6 @@ } #endif /* WIN32 */ - #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany) { @@ -67,7 +65,6 @@ } #endif /* WIN32 */ - #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_close_socket(unsigned int fd) { @@ -254,7 +251,6 @@ return NULL; } - void *skypiax_do_tcp_cli_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -338,12 +334,14 @@ #endif /* WIN32 */ if (rt > 0) { - /* read from the pipe the audio frame we are supposed to send out */ - got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, SAMPLES_PER_FRAME * sizeof(short)); - if (got != SAMPLES_PER_FRAME * sizeof(short)) { - ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); - } + /* read from the pipe the audio frame we are supposed to send out */ + got = + skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, + SAMPLES_PER_FRAME * sizeof(short)); + if (got != SAMPLES_PER_FRAME * sizeof(short)) { + ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + SAMPLES_PER_FRAME * sizeof(short)); + } if (got == SAMPLES_PER_FRAME * sizeof(short)) { if (SAMPLERATE_SKYPIAX == 8000) { @@ -356,7 +354,7 @@ cli_out[a] = cli_in[i]; a++; } - got = got * 2; + got = got * 2; } else if (SAMPLERATE_SKYPIAX == 16000) { /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */ for (i = 0; i < got / sizeof(short); i++) { @@ -366,34 +364,35 @@ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } - /* send the 16khz frame to the Skype client waiting for incoming audio */ + /* send the 16khz frame to the Skype client waiting for incoming audio */ #ifdef WIN32 - len = send(fd, (char *) cli_out, got, 0); + len = send(fd, (char *) cli_out, got, 0); #else /* WIN32 */ - len = send(fd, cli_out, got, 0); -#endif /* WIN32 */ - - if (len == -1) { - break; - } else if (len != got){ - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - skypiax_sleep(1000); - break; - } + len = send(fd, cli_out, got, 0); +#endif /* WIN32 */ - } else { + if (len == -1) { + break; + } else if (len != got) { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + skypiax_sleep(1000); + break; + } - ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, SAMPLES_PER_FRAME * sizeof(short)); - skypiax_sleep(10000); + } else { - } + ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + SAMPLES_PER_FRAME * sizeof(short)); + skypiax_sleep(10000); + + } } else { if (rt) ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); skypiax_sleep(10000); } - } + } DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(fd); break; @@ -429,7 +428,7 @@ } #endif /* WIN32 */ -/* the pipe is the audio fd for asterisk to poll on during a call */ +/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */ tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; return 0; @@ -437,7 +436,6 @@ int skypiax_skypeaudio_read(private_t * tech_pvt) { - //private_t *p; unsigned int samples; int rt; #ifndef WIN32 @@ -458,7 +456,8 @@ #endif /* WIN32 */ if (rt > 0) { samples = SAMPLES_PER_FRAME * sizeof(short); - samples = skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); + samples = + skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]); //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); @@ -1119,7 +1118,9 @@ if (rt > 0) { if (tech_pvt->SkypiaxHandles.fdesc[0]) { howmany = sizeof(read_from_pipe); - howmany = skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *)read_from_pipe, howmany); + howmany = + skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, + howmany); a = 0; for (i = 0; i < howmany; i++) { From gmaruzz at freeswitch.org Mon Feb 9 04:55:17 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 06:55:17 -0600 Subject: [Freeswitch-branches] [commit] r11700 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 06:55:17 2009 New Revision: 11700 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 06:55:17 2009 @@ -1495,35 +1495,22 @@ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_UP; - if (option_debug > 1) DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - - if (option_debug > 1) - DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", - SKYPIAX_P_LOG, id); - + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(100000); tech_pvt->skype_callflow = SKYPIAX_STATE_UP; if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); - new_inbound_channel(tech_pvt); } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); } From gmaruzz at freeswitch.org Mon Feb 9 07:49:57 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 09:49:57 -0600 Subject: [Freeswitch-branches] [commit] r11701 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 09:49:56 2009 New Revision: 11701 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 09:49:56 2009 @@ -306,32 +306,21 @@ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { -#ifdef WIN32 unsigned int fdselect; -#else - int fdselect; -#endif /* WIN32 */ int rt; fd_set fs; struct timeval to; if (!running) break; -#ifdef WIN32 - fdselect = fd; //cannot select on audioskypepipe, let's select on socket write -#else /* WIN32 */ - fdselect = tech_pvt->audioskypepipe[0]; -#endif /* WIN32 */ + fdselect = fd; FD_ZERO(&fs); FD_SET(fdselect, &fs); to.tv_usec = 2000000; //2000 msec to.tv_sec = 0; -#ifdef WIN32 - rt = select(fdselect + 1, NULL, &fs, NULL, &to); //cannot select on audioskypepipe, let's select on socket write -#else /* WIN32 */ - rt = select(fdselect + 1, &fs, NULL, NULL, &to); -#endif /* WIN32 */ + rt = select(fdselect + 1, NULL, &fs, NULL, &to); + if (rt > 0) { /* read from the pipe the audio frame we are supposed to send out */ @@ -339,7 +328,7 @@ skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, SAMPLES_PER_FRAME * sizeof(short)); if (got != SAMPLES_PER_FRAME * sizeof(short)) { - ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, SAMPLES_PER_FRAME * sizeof(short)); } @@ -365,11 +354,7 @@ } /* send the 16khz frame to the Skype client waiting for incoming audio */ -#ifdef WIN32 len = send(fd, (char *) cli_out, got, 0); -#else /* WIN32 */ - len = send(fd, cli_out, got, 0); -#endif /* WIN32 */ if (len == -1) { break; @@ -381,10 +366,8 @@ } else { - ERRORA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, SAMPLES_PER_FRAME * sizeof(short)); - skypiax_sleep(10000); - } } else { if (rt) @@ -437,44 +420,19 @@ int skypiax_skypeaudio_read(private_t * tech_pvt) { unsigned int samples; - int rt; -#ifndef WIN32 - int fdselect; - fd_set fs; - struct timeval to; -#endif /* WIN32 */ -#ifdef WIN32 - rt = 1; -#else /* WIN32 */ - fdselect = tech_pvt->audiopipe[0]; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //2000 msec - to.tv_sec = 0; - rt = select(fdselect + 1, &fs, NULL, NULL, &to); -#endif /* WIN32 */ - if (rt > 0) { - samples = SAMPLES_PER_FRAME * sizeof(short); + //samples = SAMPLES_PER_FRAME * sizeof(short); samples = - skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples); + skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short)); - //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]); - //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]); if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - //if (samples) - //ERRORA("SRV PIPE READ=====> NOT GOOD samples=%u expected=%lu\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); - //assert(samples == SAMPLES_PER_FRAME * sizeof(short)); //do a crash, please + if (samples) + WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); return 0; } else { /* A real frame */ tech_pvt->read_frame.datalen = samples; } - } else { - if (rt) - DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt); - //do nothing - } return 1; } From gmaruzz at freeswitch.org Mon Feb 9 08:10:52 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 10:10:52 -0600 Subject: [Freeswitch-branches] [commit] r11703 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Mon Feb 9 10:10:52 2009 New Revision: 11703 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Mon Feb 9 10:10:52 2009 @@ -404,6 +404,7 @@ int new_inbound_channel(private_t *tech_pvt); int outbound_channel_answered(private_t *tech_pvt); int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit); +int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); #define SKYPIAX_STATE_DOWN AST_STATE_DOWN #define SKYPIAX_STATE_RING AST_STATE_RING #define SKYPIAX_STATE_DIALING AST_STATE_DIALING Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:10:52 2009 @@ -258,3 +258,4 @@ int start_audio_threads(private_t *tech_pvt); int new_inbound_channel(private_t *tech_pvt); int outbound_channel_answered(private_t *tech_pvt); +int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 10:10:52 2009 @@ -20,6 +20,8 @@ #ifndef WIN32 XErrorHandler old_handler = 0; int xerror = 0; +#else +DWORD win32_dwThreadId; #endif /* WIN32 */ /*************************************/ @@ -421,7 +423,6 @@ { unsigned int samples; - //samples = SAMPLES_PER_FRAME * sizeof(short); samples = skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short)); @@ -436,557 +437,564 @@ return 1; } -#ifdef WIN32 - -enum { - SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully - attached and API window handle can be found - in wParam parameter */ - SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged - connection request and is waiting - for confirmation from the user. */ - /* The client is not yet attached - * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */ - SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly - denied access to client */ - SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available - at the moment. - For example, this happens when no user - is currently logged in. */ - /* Client should wait for - * SKYPECONTROLAPI_ATTACH_API_AVAILABLE - * broadcast before making any further */ - /* connection attempts. */ - SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 -}; - -char - *strsep(char **stringp, const char *delim) +int skypiax_skype_read(private_t * tech_pvt) { - char *res; - - if (!stringp || !*stringp || !**stringp) - return (char *) 0; - res = *stringp; - while (**stringp && !strchr(delim, **stringp)) - ++(*stringp); + 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 rt; + int a; + unsigned int howmany; + unsigned int i; +#ifndef WIN32 + int fdselect; + fd_set fs; + struct timeval to; +#endif /* WIN32 */ - if (**stringp) { - **stringp = '\0'; - ++(*stringp); + if (option_debug > 100) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } - return res; -} - -LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, - LPARAM ulParam) -{ - LRESULT lReturnCode; - int fIssueDefProc; - private_t *tech_pvt = NULL; - - lReturnCode = 0; - fIssueDefProc = 0; - tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA); - switch (uiMessage) { - case WM_CREATE: - tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; - SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt); - DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG); - break; - case WM_DESTROY: - NOTICA("got DESTROY\n", SKYPIAX_P_LOG); - tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; - PostQuitMessage(0); - break; - case WM_COPYDATA: - if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { - unsigned int howmany; - char msg_from_skype[2048]; - - PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam; + memset(read_from_pipe, 0, 4096); + memset(messaggio, 0, 4096); + memset(messaggio_2, 0, 4096); - memset(msg_from_skype, '\0', sizeof(msg_from_skype)); - strncpy(msg_from_skype, (const char *) poCopyData->lpData, - sizeof(msg_from_skype) - 2); +#ifdef WIN32 + rt = 1; +#else /* WIN32 */ + fdselect = tech_pvt->SkypiaxHandles.fdesc[0]; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 2000000; //500 msec + to.tv_sec = 0; + rt = select(fdselect + 1, &fs, NULL, NULL, &to); +#endif /* WIN32 */ - howmany = strlen(msg_from_skype) + 1; -//#if defined(WIN32) && !defined(__CYGWIN__) + if (rt > 0) { + if (tech_pvt->SkypiaxHandles.fdesc[0]) { + howmany = sizeof(read_from_pipe); howmany = - skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, - howmany); - //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); -//#else - //howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany); - //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); -//#endif - lReturnCode = 1; - } - break; - default: - if (tech_pvt && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { - if (uiMessage == - tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { - switch (ulParam) { - case SKYPECONTROLAPI_ATTACH_SUCCESS: - if (!tech_pvt->SkypiaxHandles.api_connected) { - DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG); - tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; - tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = - tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle; - } - break; - case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: - DEBUGA_SKYPE - ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", - SKYPIAX_P_LOG); - skypiax_sleep(5000); - if (!tech_pvt->SkypiaxHandles.api_connected) { - SendMessage(HWND_BROADCAST, - tech_pvt->SkypiaxHandles. - win32_uiGlobal_MsgID_SkypeControlAPIDiscover, - (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, - 0); - } - break; - case SKYPECONTROLAPI_ATTACH_REFUSED: - ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: - ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: - DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG); - skypiax_sleep(5000); - if (!tech_pvt->SkypiaxHandles.api_connected) { - SendMessage(HWND_BROADCAST, - tech_pvt->SkypiaxHandles. - win32_uiGlobal_MsgID_SkypeControlAPIDiscover, - (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, - 0); - } - break; - default: - WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG); - } - lReturnCode = 1; - break; - } - } - fIssueDefProc = 1; - break; - } - if (fIssueDefProc) - lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam); - return (lReturnCode); -} + skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, + howmany); -int win32_Initialize_CreateWindowClass(private_t * tech_pvt) -{ - unsigned char *paucUUIDString; - RPC_STATUS lUUIDResult; - int fReturnStatus; - UUID oUUID; + a = 0; + for (i = 0; i < howmany; i++) { + messaggio[a] = read_from_pipe[i]; + a++; - fReturnStatus = 0; - lUUIDResult = UuidCreate(&oUUID); - tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = - (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); - if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL - && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) { - if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) { - WNDCLASS oWindowClass; + if (read_from_pipe[i] == '\0') { - strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-"); - strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, - (char *) paucUUIDString); + //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); + DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio); - oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present; - oWindowClass.cbClsExtra = 0; - oWindowClass.cbWndExtra = 0; - oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle; - oWindowClass.hIcon = NULL; - oWindowClass.hCursor = NULL; - oWindowClass.hbrBackground = NULL; - oWindowClass.lpszMenuName = NULL; - oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName; + if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified, + just authorized */ + DEBUGA_SKYPE + ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", + SKYPIAX_P_LOG); + skypiax_sleep(1000000); + skypiax_skype_write(tech_pvt, "PROTOCOL 6"); + skypiax_sleep(10000); + return 0; + } - if (RegisterClass(&oWindowClass) != 0) - fReturnStatus = 1; + if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { + ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", + SKYPIAX_P_LOG, messaggio); + tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + tech_pvt->skype_call_id[0] = '\0'; - RpcStringFree(&paucUUIDString); - } - } - if (fReturnStatus == 0) - CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle), - tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; - return (fReturnStatus); -} + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } -void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt) -{ - UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, - tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle); - CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle), - tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; -} + strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1); -int win32_Initialize_CreateMainWindow(private_t * tech_pvt) -{ - tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = - CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, - tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "", - WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, - 128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle, - tech_pvt); - return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0); -} + buf = messaggio; + stringp = &buf; + where = strsep(stringp, " "); + if (!where) { + WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio); + } -void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt) -{ - if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL) - DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle), - tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; -} + if (!strcasecmp(messaggio, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG, + * messaggio_2, &messaggio_2[11]); */ + memset(tech_pvt->skype_friends, 0, 4096); + strncpy(tech_pvt->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(tech_pvt->skype_fullname, 0, 512); + strncpy(tech_pvt->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(tech_pvt->skype_displayname, 0, 512); + strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511); + } + if (!strcasecmp(messaggio, "ERROR")) { + ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); + tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + tech_pvt->skype_call_id[0] = '\0'; -DWORD win32_dwThreadId; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } + if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) { + strncpy(obj, where, sizeof(obj) - 1); -void *skypiax_do_skypeapi_thread_func(void *obj) -{ - /* create window class */ - /* create dummy/hidden window for processing messages */ - /* run message loop thread */ - /* do application control until exit */ - /* exit: send QUIT message to our own window */ - /* wait until thred terminates */ - /* destroy main window */ - /* destroy window class */ + where = strsep(stringp, " "); - private_t *tech_pvt = obj; -#if defined(WIN32) && !defined(__CYGWIN__) - switch_status_t rv; + strncpy(id, where, sizeof(id) - 1); - switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], - &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); - rv = - switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], - &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); -#else /* WIN32 */ - if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { - fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); - } -#endif /* WIN32 */ + if (!strcasecmp(id, tech_pvt->skype_user)) { + tech_pvt->SkypiaxHandles.api_connected = 1; + DEBUGA_SKYPE + ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); + } + } - tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = - RegisterWindowMessage("SkypeControlAPIAttach"); - tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = - RegisterWindowMessage("SkypeControlAPIDiscover"); + if (!strcasecmp(messaggio, "USER")) { + strncpy(obj, where, sizeof(obj) - 1); - skypiax_sleep(2000000); + where = strsep(stringp, " "); - if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 - && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { - if (win32_Initialize_CreateWindowClass(tech_pvt)) { - if (win32_Initialize_CreateMainWindow(tech_pvt)) { - if (SendMessage - (HWND_BROADCAST, - tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover, - (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) { - tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = - tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle; - while (1) { - MSG oMessage; - if (!running) - break; - while (GetMessage(&oMessage, 0, 0, 0)) { - TranslateMessage(&oMessage); - DispatchMessage(&oMessage); - } - } - } - win32_DeInitialize_DestroyMainWindow(tech_pvt); - } - win32_DeInitialize_DestroyWindowClass(tech_pvt); - } - } + strncpy(id, where, sizeof(id) - 1); - return NULL; -} + where = strsep(stringp, " "); -#else /* NOT WIN32 */ + strncpy(prop, where, sizeof(prop) - 1); -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - (void) dpy; - private_t *tech_pvt = NULL; + if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, prop); - xerror = err->error_code; - ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); - return 0; /* ignore the error */ -} + //FIXME: TODO: allow authorization based on config param + sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } -static void X11_errors_trap(void) -{ - xerror = 0; - old_handler = XSetErrorHandler(X11_errors_handler); -} + if (!strcasecmp(messaggio, "MESSAGE")) { + strncpy(obj, where, sizeof(obj) - 1); -static int X11_errors_untrap(void) -{ - XSetErrorHandler(old_handler); - return (xerror != BadValue) && (xerror != BadWindow); -} + where = strsep(stringp, " "); -int skypiax_skype_send_message(struct SkypiaxHandles *SkypiaxHandles, - const char *message_P) -{ + strncpy(id, where, sizeof(id) - 1); - Window w_P; - Display *disp; - Window handle_P; - int ok; - private_t *tech_pvt = NULL; + where = strsep(stringp, " "); - w_P = SkypiaxHandles->skype_win; - disp = SkypiaxHandles->disp; - handle_P = SkypiaxHandles->win; + strncpy(prop, where, sizeof(prop) - 1); - Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); - unsigned int pos = 0; - unsigned int len = strlen(message_P); - XEvent e; + if (!strcasecmp(prop, "STATUS")) { - memset(&e, 0, sizeof(e)); - e.xclient.type = ClientMessage; - e.xclient.message_type = atom1; /* leading message */ - e.xclient.display = disp; - e.xclient.window = handle_P; - e.xclient.format = 8; + where = strsep(stringp, " "); - X11_errors_trap(); - //XLockDisplay(disp); - do { - unsigned int i; - for (i = 0; i < 20 && i + pos <= len; ++i) - e.xclient.data.b[i] = message_P[i + pos]; - XSendEvent(disp, w_P, False, 0, &e); + strncpy(value, where, sizeof(value) - 1); - e.xclient.message_type = atom2; /* following messages */ - pos += i; - } while (pos <= len); + if (!strcasecmp(value, "RECEIVED")) { + char msg_to_skype[256]; + DEBUGA_SKYPE + ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, prop, value); - XSync(disp, False); - ok = X11_errors_untrap(); + //FIXME: TODO: allow authorization based on config param + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } else if (!strcasecmp(prop, "BODY")) { + char msg_to_skype[256]; - if (!ok) - ERRORA("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); - //XUnlockDisplay(disp); + DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, prop); - return 1; -} + //FIXME: TODO: on config param ??? + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } -int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles) -{ - Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True); + } - Atom type_ret; - int format_ret; - unsigned long nitems_ret; - unsigned long bytes_after_ret; - unsigned char *prop; - int status; - private_t *tech_pvt = NULL; + if (!strcasecmp(messaggio, "CALL")) { - X11_errors_trap(); - //XLockDisplay(disp); - status = - XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp), - skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, - &nitems_ret, &bytes_after_ret, &prop); - //XUnlockDisplay(disp); - X11_errors_untrap(); + strncpy(obj, where, sizeof(obj) - 1); - /* sanity check */ - if (status != Success || format_ret != 32 || nitems_ret != 1) { - SkypiaxHandles->skype_win = (Window) - 1; - DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); - return 0; - } + where = strsep(stringp, " "); - SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff; - DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, - (unsigned int) SkypiaxHandles->skype_win); - return 1; -} + strncpy(id, where, sizeof(id) - 1); -void skypiax_skype_clean_disp(void *data) -{ + where = strsep(stringp, " "); - int *dispptr; - int disp; - private_t *tech_pvt = NULL; + strncpy(prop, where, sizeof(prop) - 1); - dispptr = data; - disp = *dispptr; + where = strsep(stringp, " "); - if (disp) { - DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp); - close(disp); - DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG); - } else { - DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG); - } - DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG); - skypiax_sleep(1000); -} - -void *skypiax_do_skypeapi_thread_func(void *obj) -{ - - private_t *tech_pvt = obj; - struct SkypiaxHandles *SkypiaxHandles; - char buf[512]; - Display *disp = NULL; - Window root = -1; - Window win = -1; - - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - - if (!strlen(tech_pvt->X11_display)) - strcpy(tech_pvt->X11_display, getenv("DISPLAY")); - - if (!tech_pvt->tcp_srv_port) - tech_pvt->tcp_srv_port = 10160; - - if (!tech_pvt->tcp_cli_port) - tech_pvt->tcp_cli_port = 10161; + strncpy(value, where, sizeof(value) - 1); - if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { - fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); - } - SkypiaxHandles = &tech_pvt->SkypiaxHandles; - disp = XOpenDisplay(tech_pvt->X11_display); - if (!disp) { - ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG, - tech_pvt->X11_display); - running = 0; - return NULL; - } else { - DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display); - } + where = strsep(stringp, " "); - int xfd; - xfd = XConnectionNumber(disp); - fcntl(xfd, F_SETFD, FD_CLOEXEC); + if (option_debug > 101) + 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"); - //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd); + if (!strcasecmp(prop, "PARTNER_HANDLE")) { + strncpy(tech_pvt->callid_number, value, + sizeof(tech_pvt->callid_number) - 1); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_number); + return CALLFLOW_INCOMING_RING; + } + if (!strcasecmp(prop, "PARTNER_DISPNAME")) { + snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", + value, where ? " " : "", where ? where : ""); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_name); + } + 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->interface_state = SKYPIAX_STATE_PRERING; + } - SkypiaxHandles->disp = disp; + if (!strcasecmp(prop, "DTMF")) { - if (skypiax_skype_present(SkypiaxHandles)) { - root = DefaultRootWindow(disp); - win = - XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, - BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, - DefaultScreen - (disp))); + DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); - SkypiaxHandles->win = win; + dtmf_received(tech_pvt, value); + } - snprintf(buf, 512, "NAME skypiax"); + if (!strcasecmp(prop, "FAILUREREASON")) { + 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, tech_pvt->skype_call_id)) { + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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 (!skypiax_skype_send_message(SkypiaxHandles, buf)) { - ERRORA - ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", - SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running = 0; - return NULL; - } + if (!strcasecmp(prop, "STATUS")) { - snprintf(buf, 512, "PROTOCOL 6"); - if (!skypiax_skype_send_message(SkypiaxHandles, buf)) { - ERRORA - ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", - SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running = 0; - return NULL; - } + if (!strcasecmp(value, "RINGING")) { + char msg_to_skype[1024]; + if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { + /* we are not calling out */ - /* perform an events loop */ - XEvent an_event; - char buf[21]; /* can't be longer */ - char buffer[17000]; - char *b; - int i; + if (!strlen(tech_pvt->skype_call_id)) { //FIXME + /* we are not inside an active call */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RING; + /* no owner, no active call, let's answer */ + skypiax_skype_write(tech_pvt, "SET AGC OFF"); + skypiax_sleep(10000); + skypiax_skype_write(tech_pvt, "SET AEC OFF"); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + if (option_debug) + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", + SKYPIAX_P_LOG, id); + strncpy(tech_pvt->skype_call_id, id, + sizeof(tech_pvt->skype_call_id) - 1); + } else { + /* we're owned, we're in a call, let's refuse */ + sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(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); - b = buffer; + } + } else { + /* we are calling out */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RINGING; + //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); + strncpy(tech_pvt->skype_call_id, id, + sizeof(tech_pvt->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")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + //FIXME ast_queue_control(tech_pvt->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")) { + DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); - while (1) { - XNextEvent(disp, &an_event); - if (!running) - break; - switch (an_event.type) { - case ClientMessage: + } else if (!strcasecmp(value, "FINISHED")) { + //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; - if (an_event.xclient.format != 8) - break; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } - for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i) - buf[i] = an_event.xclient.data.b[i]; + } else if (!strcasecmp(value, "CANCELLED")) { + tech_pvt->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); + tech_pvt->skype_call_id[0] = '\0'; - buf[i] = '\0'; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } else if (!strcasecmp(value, "FAILED")) { + tech_pvt->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); + tech_pvt->skype_call_id[0] = '\0'; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return CALLFLOW_INCOMING_HANGUP; + } else if (!strcasecmp(value, "REFUSED")) { + if (!strcasecmp(id, tech_pvt->skype_call_id)) { + /* this is the id of the call we are in, probably we generated it */ + tech_pvt->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(tech_pvt->skype_call_id, id, + sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + tech_pvt->skype_call_id[0] = '\0'; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + 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); - strcat(buffer, buf); + } + } else if (!strcasecmp(value, "ROUTING")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "UNPLACED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "INPROGRESS")) { + char msg_to_skype[1024]; + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_UP; + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_write(tech_pvt, msg_to_skype); - if (i < 20) { /* last fragment */ - unsigned int howmany; + tech_pvt->skype_callflow = SKYPIAX_STATE_UP; - howmany = strlen(b) + 1; + if (!strlen(tech_pvt->session_uuid_str)) { + DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); + new_inbound_channel(tech_pvt); + } else { + DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); + outbound_channel_answered(tech_pvt); + } - howmany = write(SkypiaxHandles->fdesc[1], b, howmany); - memset(buffer, '\0', 17000); - } + } 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 - break; - default: - break; - } } - } else { - ERRORA - ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", - SKYPIAX_P_LOG); - running = 0; - return NULL; } - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - running = 0; - return NULL; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + return 0; } -#endif // WIN32 -int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype) +int skypiax_skype_senddigit(private_t * tech_pvt, char digit) +{ + char msg_to_skype[1024]; + if (option_debug > 10) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + + DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); + + sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit); + + skypiax_skype_write(tech_pvt, msg_to_skype); + + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return 0; +} + +int skypiax_skype_call(private_t * tech_pvt, char *rdest, int timeout) { + char msg_to_skype[1024]; + + if (option_debug > 10) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + skypiax_sleep(5000); + DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); + skypiax_skype_write(tech_pvt, "SET AGC OFF"); + skypiax_sleep(10000); + skypiax_skype_write(tech_pvt, "SET AEC OFF"); + skypiax_sleep(10000); + + sprintf(msg_to_skype, "CALL %s", rdest); + if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) { + + ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return -1; + } + return 0; +} + + + #ifdef WIN32 + +enum { + SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully + attached and API window handle can be found + in wParam parameter */ + SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged + connection request and is waiting + for confirmation from the user. */ + /* The client is not yet attached + * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */ + SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly + denied access to client */ + SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available + at the moment. + For example, this happens when no user + is currently logged in. */ + /* Client should wait for + * SKYPECONTROLAPI_ATTACH_API_AVAILABLE + * broadcast before making any further */ + /* connection attempts. */ + SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 +}; + +/* Visual C do not have strsep? */ +char + *strsep(char **stringp, const char *delim) +{ + char *res; + + if (!stringp || !*stringp || !**stringp) + return (char *) 0; + + res = *stringp; + while (**stringp && !strchr(delim, **stringp)) + ++(*stringp); + + if (**stringp) { + **stringp = '\0'; + ++(*stringp); + } + + return res; +} + +int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype) +{ static char acInputRow[1024]; COPYDATASTRUCT oCopyData; -#else /* WIN32 */ - struct SkypiaxHandles *SkypiaxHandles; -#endif /* WIN32 */ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); -#ifdef WIN32 - if (option_debug > 100) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } @@ -1003,7 +1011,7 @@ (WPARAM) tech_pvt->SkypiaxHandles.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", + ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n", SKYPIAX_P_LOG); if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -1011,23 +1019,6 @@ return -1; } } -#else /* WIN32 */ - - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - SkypiaxHandles = &tech_pvt->SkypiaxHandles; - - if (!skypiax_skype_send_message(SkypiaxHandles, 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); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } -#endif /* WIN32 */ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -1036,507 +1027,508 @@ } -int skypiax_skype_read(private_t * tech_pvt) +LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, + LPARAM ulParam) { + LRESULT lReturnCode; + int fIssueDefProc; + private_t *tech_pvt = NULL; - 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 rt; - int a; - unsigned int howmany; - unsigned int i; -#ifndef WIN32 - int fdselect; - fd_set fs; - struct timeval to; -#endif /* WIN32 */ - - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } + lReturnCode = 0; + fIssueDefProc = 0; + tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA); + switch (uiMessage) { + case WM_CREATE: + tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; + SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt); + DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG); + break; + case WM_DESTROY: + NOTICA("got DESTROY\n", SKYPIAX_P_LOG); + tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; + PostQuitMessage(0); + break; + case WM_COPYDATA: + if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { + unsigned int howmany; + char msg_from_skype[2048]; - memset(read_from_pipe, 0, 4096); - memset(messaggio, 0, 4096); - memset(messaggio_2, 0, 4096); + PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam; -#ifdef WIN32 - rt = 1; -#else /* WIN32 */ - fdselect = tech_pvt->SkypiaxHandles.fdesc[0]; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //500 msec - to.tv_sec = 0; - rt = select(fdselect + 1, &fs, NULL, NULL, &to); -#endif /* WIN32 */ + memset(msg_from_skype, '\0', sizeof(msg_from_skype)); + strncpy(msg_from_skype, (const char *) poCopyData->lpData, + sizeof(msg_from_skype) - 2); - if (rt > 0) { - if (tech_pvt->SkypiaxHandles.fdesc[0]) { - howmany = sizeof(read_from_pipe); + howmany = strlen(msg_from_skype) + 1; howmany = - skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, - howmany); - - a = 0; - for (i = 0; i < howmany; i++) { - messaggio[a] = read_from_pipe[i]; - a++; - - if (read_from_pipe[i] == '\0') { - - //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); - DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio); - - if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified, - just authorized */ - DEBUGA_SKYPE - ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", - SKYPIAX_P_LOG); - skypiax_sleep(1000000); - skypiax_skype_write(tech_pvt, "PROTOCOL 6"); - skypiax_sleep(10000); - return 0; - } - - if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", - SKYPIAX_P_LOG, messaggio); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_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(tech_pvt->skype_friends, 0, 4096); - strncpy(tech_pvt->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(tech_pvt->skype_fullname, 0, 512); - strncpy(tech_pvt->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(tech_pvt->skype_displayname, 0, 512); - strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511); + skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, + howmany); + //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); + lReturnCode = 1; + } + break; + default: + if (tech_pvt && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { + if (uiMessage == + tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { + switch (ulParam) { + case SKYPECONTROLAPI_ATTACH_SUCCESS: + if (!tech_pvt->SkypiaxHandles.api_connected) { + DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG); + tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; + tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = + tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle; } - if (!strcasecmp(messaggio, "ERROR")) { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } + break; + case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: + DEBUGA_SKYPE + ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", + SKYPIAX_P_LOG); + skypiax_sleep(5000); + if (!tech_pvt->SkypiaxHandles.api_connected) { + SendMessage(HWND_BROADCAST, + tech_pvt->SkypiaxHandles. + win32_uiGlobal_MsgID_SkypeControlAPIDiscover, + (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, + 0); } - if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) { - strncpy(obj, where, sizeof(obj) - 1); - - where = strsep(stringp, " "); - - strncpy(id, where, sizeof(id) - 1); - - if (!strcasecmp(id, tech_pvt->skype_user)) { - tech_pvt->SkypiaxHandles.api_connected = 1; - DEBUGA_SKYPE - ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); - } + break; + case SKYPECONTROLAPI_ATTACH_REFUSED: + ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG); + break; + case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: + ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG); + break; + case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: + DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG); + skypiax_sleep(5000); + if (!tech_pvt->SkypiaxHandles.api_connected) { + SendMessage(HWND_BROADCAST, + tech_pvt->SkypiaxHandles. + win32_uiGlobal_MsgID_SkypeControlAPIDiscover, + (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, + 0); } + break; + default: + WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG); + } + lReturnCode = 1; + break; + } + } + fIssueDefProc = 1; + break; + } + if (fIssueDefProc) + lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam); + return (lReturnCode); +} - if (!strcasecmp(messaggio, "USER")) { - strncpy(obj, where, sizeof(obj) - 1); - - where = strsep(stringp, " "); +int win32_Initialize_CreateWindowClass(private_t * tech_pvt) +{ + unsigned char *paucUUIDString; + RPC_STATUS lUUIDResult; + int fReturnStatus; + UUID oUUID; - strncpy(id, where, sizeof(id) - 1); + fReturnStatus = 0; + lUUIDResult = UuidCreate(&oUUID); + tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = + (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); + if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL + && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) { + if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) { + WNDCLASS oWindowClass; - where = strsep(stringp, " "); + strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-"); + strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, + (char *) paucUUIDString); - strncpy(prop, where, sizeof(prop) - 1); + oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present; + oWindowClass.cbClsExtra = 0; + oWindowClass.cbWndExtra = 0; + oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle; + oWindowClass.hIcon = NULL; + oWindowClass.hCursor = NULL; + oWindowClass.hbrBackground = NULL; + oWindowClass.lpszMenuName = NULL; + oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName; - if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop); + if (RegisterClass(&oWindowClass) != 0) + fReturnStatus = 1; - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } - } + RpcStringFree(&paucUUIDString); + } + } + if (fReturnStatus == 0) + CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle), + tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; + return (fReturnStatus); +} - if (!strcasecmp(messaggio, "MESSAGE")) { - strncpy(obj, where, sizeof(obj) - 1); +void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt) +{ + UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, + tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle); + CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle), + tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; +} - where = strsep(stringp, " "); +int win32_Initialize_CreateMainWindow(private_t * tech_pvt) +{ + tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = + CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, + tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "", + WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, + 128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle, + tech_pvt); + return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0); +} - strncpy(id, where, sizeof(id) - 1); +void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt) +{ + if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL) + DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle), + tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; +} - where = strsep(stringp, " "); - strncpy(prop, where, sizeof(prop) - 1); +void *skypiax_do_skypeapi_thread_func(void *obj) +{ + private_t *tech_pvt = obj; +#if defined(WIN32) && !defined(__CYGWIN__) + switch_status_t rv; - if (!strcasecmp(prop, "STATUS")) { + switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], + &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); + rv = + switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0], + &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool); +#else /* WIN32 */ + if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { + fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); + fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); + } +#endif /* WIN32 */ - where = strsep(stringp, " "); + tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = + RegisterWindowMessage("SkypeControlAPIAttach"); + tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = + RegisterWindowMessage("SkypeControlAPIDiscover"); - strncpy(value, where, sizeof(value) - 1); + skypiax_sleep(2000000); - if (!strcasecmp(value, "RECEIVED")) { - char msg_to_skype[256]; - DEBUGA_SKYPE - ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop, value); - - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } - } else if (!strcasecmp(prop, "BODY")) { - char msg_to_skype[256]; - - DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop); - - //FIXME: TODO: on config param ??? - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); + if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 + && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { + if (win32_Initialize_CreateWindowClass(tech_pvt)) { + if (win32_Initialize_CreateMainWindow(tech_pvt)) { + if (SendMessage + (HWND_BROADCAST, + tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover, + (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) { + tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = + tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle; + while (1) { + MSG oMessage; + if (!running) + break; + while (GetMessage(&oMessage, 0, 0, 0)) { + TranslateMessage(&oMessage); + DispatchMessage(&oMessage); } - } + } + win32_DeInitialize_DestroyMainWindow(tech_pvt); + } + win32_DeInitialize_DestroyWindowClass(tech_pvt); + } + } - 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 > 101) - 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(tech_pvt->callid_number, value, - sizeof(tech_pvt->callid_number) - 1); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_number); - return CALLFLOW_INCOMING_RING; - } - if (!strcasecmp(prop, "PARTNER_DISPNAME")) { - snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", - value, where ? " " : "", where ? where : ""); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_name); - } - 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->interface_state = SKYPIAX_STATE_PRERING; - } - - if (!strcasecmp(prop, "DTMF")) { - - DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); - - dtmf_received(tech_pvt, value); - } - - if (!strcasecmp(prop, "FAILUREREASON")) { - 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, tech_pvt->skype_call_id)) { - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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 (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { - /* we are not calling out */ + return NULL; +} - if (!strlen(tech_pvt->skype_call_id)) { //FIXME - /* we are not inside an active call */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RING; - /* no owner, no active call, let's answer */ - skypiax_skype_write(tech_pvt, "SET AGC OFF"); - skypiax_sleep(10000); - skypiax_skype_write(tech_pvt, "SET AEC OFF"); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - if (option_debug) - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", - SKYPIAX_P_LOG, id); - strncpy(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->skype_call_id) - 1); - } else { - /* we're owned, we're in a call, let's refuse */ - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(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 /* NOT WIN32 */ +int X11_errors_handler(Display * dpy, XErrorEvent * err) +{ + (void) dpy; + private_t *tech_pvt = NULL; - } - } else { - /* we are calling out */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RINGING; - //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); - strncpy(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->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")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - //FIXME ast_queue_control(tech_pvt->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")) { - DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); + xerror = err->error_code; + ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); + return 0; /* ignore the error */ +} - } else if (!strcasecmp(value, "FINISHED")) { - //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; +static void X11_errors_trap(void) +{ + xerror = 0; + old_handler = XSetErrorHandler(X11_errors_handler); +} - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } +static int X11_errors_untrap(void) +{ + XSetErrorHandler(old_handler); + return (xerror != BadValue) && (xerror != BadWindow); +} - } else if (!strcasecmp(value, "CANCELLED")) { - tech_pvt->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); - tech_pvt->skype_call_id[0] = '\0'; +int skypiax_skype_send_message(struct SkypiaxHandles *SkypiaxHandles, + const char *message_P) +{ - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } else if (!strcasecmp(value, "FAILED")) { - tech_pvt->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); - tech_pvt->skype_call_id[0] = '\0'; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "REFUSED")) { - if (!strcasecmp(id, tech_pvt->skype_call_id)) { - /* this is the id of the call we are in, probably we generated it */ - tech_pvt->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(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - 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); + Window w_P; + Display *disp; + Window handle_P; + int ok; + private_t *tech_pvt = NULL; - } - } else if (!strcasecmp(value, "ROUTING")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "UNPLACED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_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_skype_write(tech_pvt, msg_to_skype); + w_P = SkypiaxHandles->skype_win; + disp = SkypiaxHandles->disp; + handle_P = SkypiaxHandles->win; - tech_pvt->skype_callflow = SKYPIAX_STATE_UP; + Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); + Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); + unsigned int pos = 0; + unsigned int len = strlen(message_P); + XEvent e; - if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); - new_inbound_channel(tech_pvt); - } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); - } + memset(&e, 0, sizeof(e)); + e.xclient.type = ClientMessage; + e.xclient.message_type = atom1; /* leading message */ + e.xclient.display = disp; + e.xclient.window = handle_P; + e.xclient.format = 8; - } else { - WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, - id, value); + X11_errors_trap(); + //XLockDisplay(disp); + do { + unsigned int i; + for (i = 0; i < 20 && i + pos <= len; ++i) + e.xclient.data.b[i] = message_P[i + pos]; + XSendEvent(disp, w_P, False, 0, &e); - } - } //STATUS + e.xclient.message_type = atom2; /* following messages */ + pos += i; + } while (pos <= len); - } //CALL + XSync(disp, False); + ok = X11_errors_untrap(); - a = 0; - } //message end - } //read_from_pipe + if (!ok) + ERRORA("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); + //XUnlockDisplay(disp); + + return 1; +} +int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype) +{ + struct SkypiaxHandles *SkypiaxHandles; + + DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); + + if (option_debug > 100) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + SkypiaxHandles = &tech_pvt->SkypiaxHandles; + if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) { + ERRORA + ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n", + SKYPIAX_P_LOG); + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } + return -1; } if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; + } -int skypiax_skype_senddigit(private_t * tech_pvt, char digit) + +int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles) { - char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True); + + Atom type_ret; + int format_ret; + unsigned long nitems_ret; + unsigned long bytes_after_ret; + unsigned char *prop; + int status; + private_t *tech_pvt = NULL; + + X11_errors_trap(); + //XLockDisplay(disp); + status = + XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp), + skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, + &nitems_ret, &bytes_after_ret, &prop); + //XUnlockDisplay(disp); + X11_errors_untrap(); + + /* sanity check */ + if (status != Success || format_ret != 32 || nitems_ret != 1) { + SkypiaxHandles->skype_win = (Window) - 1; + DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); + return 0; } - DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); + SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff; + DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, + (unsigned int) SkypiaxHandles->skype_win); + return 1; +} - sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit); +void skypiax_skype_clean_disp(void *data) +{ - skypiax_skype_write(tech_pvt, msg_to_skype); + int *dispptr; + int disp; + private_t *tech_pvt = NULL; - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + dispptr = data; + disp = *dispptr; + + if (disp) { + DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp); + close(disp); + DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG); + } else { + DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG); } - return 0; + DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG); + skypiax_sleep(1000); } -int skypiax_skype_call(private_t * tech_pvt, char *rdest, int timeout) +void *skypiax_do_skypeapi_thread_func(void *obj) { - char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + private_t *tech_pvt = obj; + struct SkypiaxHandles *SkypiaxHandles; + char buf[512]; + Display *disp = NULL; + Window root = -1; + Window win = -1; + + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + + if (!strlen(tech_pvt->X11_display)) + strcpy(tech_pvt->X11_display, getenv("DISPLAY")); + + if (!tech_pvt->tcp_srv_port) + tech_pvt->tcp_srv_port = 10160; + + if (!tech_pvt->tcp_cli_port) + tech_pvt->tcp_cli_port = 10161; + + if (pipe(tech_pvt->SkypiaxHandles.fdesc)) { + fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); + fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); + } + SkypiaxHandles = &tech_pvt->SkypiaxHandles; + disp = XOpenDisplay(tech_pvt->X11_display); + if (!disp) { + ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG, + tech_pvt->X11_display); + running = 0; + return NULL; + } else { + DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display); } - skypiax_sleep(5000); - DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); - skypiax_skype_write(tech_pvt, "SET AGC OFF"); - skypiax_sleep(10000); - skypiax_skype_write(tech_pvt, "SET AEC OFF"); - skypiax_sleep(10000); - sprintf(msg_to_skype, "CALL %s", rdest); - if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) { + int xfd; + xfd = XConnectionNumber(disp); + fcntl(xfd, F_SETFD, FD_CLOEXEC); - ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); - if (option_debug > 10) { + SkypiaxHandles->disp = disp; + + if (skypiax_skype_present(SkypiaxHandles)) { + root = DefaultRootWindow(disp); + win = + XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, + BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, + DefaultScreen + (disp))); + + SkypiaxHandles->win = win; + + snprintf(buf, 512, "NAME skypiax"); + + if (!skypiax_skype_send_message(SkypiaxHandles, buf)) { + ERRORA + ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", + SKYPIAX_P_LOG); DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + running = 0; + return NULL; } - return -1; + + snprintf(buf, 512, "PROTOCOL 6"); + if (!skypiax_skype_send_message(SkypiaxHandles, buf)) { + ERRORA + ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", + SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + running = 0; + return NULL; + } + + /* perform an events loop */ + XEvent an_event; + char buf[21]; /* can't be longer */ + char buffer[17000]; + char *b; + int i; + + b = buffer; + + while (1) { + XNextEvent(disp, &an_event); + if (!running) + break; + switch (an_event.type) { + case ClientMessage: + + if (an_event.xclient.format != 8) + break; + + for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i) + buf[i] = an_event.xclient.data.b[i]; + + buf[i] = '\0'; + + strcat(buffer, buf); + + if (i < 20) { /* last fragment */ + unsigned int howmany; + + howmany = strlen(b) + 1; + + howmany = write(SkypiaxHandles->fdesc[1], b, howmany); + memset(buffer, '\0', 17000); + } + + break; + default: + break; + } + } + } else { + ERRORA + ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", + SKYPIAX_P_LOG); + running = 0; + return NULL; } - //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); - return 0; + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + running = 0; + return NULL; + } +#endif // WIN32 + + From gmaruzz at freeswitch.org Mon Feb 9 08:34:49 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 10:34:49 -0600 Subject: [Freeswitch-branches] [commit] r11705 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 10:34:49 2009 New Revision: 11705 Log: skypiax: cleaning added strsep() to skypiax.h, Visual C lack it Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:34:49 2009 @@ -259,3 +259,5 @@ int new_inbound_channel(private_t *tech_pvt); int outbound_channel_answered(private_t *tech_pvt); int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); +/* Visual C do not have strsep ? */ +char *strsep(char **stringp, const char *delim); From gmaruzz at freeswitch.org Mon Feb 9 08:56:44 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 10:56:44 -0600 Subject: [Freeswitch-branches] [commit] r11707 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Mon Feb 9 10:56:44 2009 New Revision: 11707 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Mon Feb 9 10:56:44 2009 @@ -405,6 +405,16 @@ int outbound_channel_answered(private_t *tech_pvt); int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit); int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany); +int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany); +/* Visual C do not have strsep ? */ +char *strsep(char **stringp, const char *delim); +#else +int skypiax_pipe_read(int pipe, short *buf, int howmany); +int skypiax_pipe_write(int pipe, short *buf, int howmany); +#endif /* WIN32 */ +int skypiax_close_socket(unsigned int fd); #define SKYPIAX_STATE_DOWN AST_STATE_DOWN #define SKYPIAX_STATE_RING AST_STATE_RING #define SKYPIAX_STATE_DIALING AST_STATE_DIALING Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:56:44 2009 @@ -259,5 +259,13 @@ int new_inbound_channel(private_t *tech_pvt); int outbound_channel_answered(private_t *tech_pvt); int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany); +int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany); /* Visual C do not have strsep ? */ char *strsep(char **stringp, const char *delim); +#else +int skypiax_pipe_read(int pipe, short *buf, int howmany); +int skypiax_pipe_write(int pipe, short *buf, int howmany); +#endif /* WIN32 */ +int skypiax_close_socket(unsigned int fd); Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 10:56:44 2009 @@ -7,8 +7,6 @@ extern char *skypiax_console_active; #else /* FREESWITCH */ #define skypiax_sleep switch_sleep -//#define skypiax_pipe_write switch_file_write -//#define skypiax_pipe_read switch_file_read extern switch_memory_pool_t *skypiax_module_pool; extern switch_endpoint_interface_t *skypiax_endpoint_interface; #endif /* ASTERISK */ @@ -17,76 +15,14 @@ extern int running; /*************************************/ -#ifndef WIN32 +#ifdef WIN32 +DWORD win32_dwThreadId; +#else XErrorHandler old_handler = 0; int xerror = 0; -#else -DWORD win32_dwThreadId; #endif /* WIN32 */ /*************************************/ -#if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany) -{ - switch_size_t quantity; - - quantity = howmany; - - switch_file_read(pipe, buf, &quantity); - - howmany = quantity; - - return howmany; -} -#else /* WIN32 */ -int skypiax_pipe_read(int pipe, short *buf, int howmany) -{ - howmany = read(pipe, buf, howmany); - return howmany; -} -#endif /* WIN32 */ - -#if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany) -{ - switch_size_t quantity; - - quantity = howmany; - - switch_file_write(pipe, buf, &quantity); - - howmany = quantity; - - return howmany; -} -#else /* WIN32 */ -int skypiax_pipe_write(int pipe, short *buf, int howmany) -{ - howmany = write(pipe, buf, howmany); - return howmany; -} -#endif /* WIN32 */ - -#if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_close_socket(unsigned int fd) -{ - int res; - - res = closesocket(fd); - - return res; -} -#else /* WIN32 */ -int skypiax_close_socket(unsigned int fd) -{ - int res; - - res = close(fd); - - return res; -} -#endif /* WIN32 */ - void *skypiax_do_tcp_srv_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -941,6 +877,63 @@ return 0; } +/***************************/ +/* PLATFORM SPECIFIC */ +/***************************/ +#if defined(WIN32) && !defined(__CYGWIN__) +int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany) +{ + switch_size_t quantity; + + quantity = howmany; + + switch_file_read(pipe, buf, &quantity); + + howmany = quantity; + + return howmany; +} +int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany) +{ + switch_size_t quantity; + + quantity = howmany; + + switch_file_write(pipe, buf, &quantity); + + howmany = quantity; + + return howmany; +} +int skypiax_close_socket(unsigned int fd) +{ + int res; + + res = closesocket(fd); + + return res; +} + +#else /* WIN32 */ +int skypiax_pipe_read(int pipe, short *buf, int howmany) +{ + howmany = read(pipe, buf, howmany); + return howmany; +} +int skypiax_pipe_write(int pipe, short *buf, int howmany) +{ + howmany = write(pipe, buf, howmany); + return howmany; +} +int skypiax_close_socket(unsigned int fd) +{ + int res; + + res = close(fd); + + return res; +} +#endif /* WIN32 */ #ifdef WIN32 From gmaruzz at freeswitch.org Mon Feb 9 09:22:53 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 11:22:53 -0600 Subject: [Freeswitch-branches] [commit] r11708 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Mon Feb 9 11:22:53 2009 New Revision: 11708 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Mon Feb 9 11:22:53 2009 @@ -180,16 +180,10 @@ { struct skypiax_pvt *p = c->tech_pvt; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* queue the frame */ if (p) p->control_to_send = control; else { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control); @@ -198,9 +192,6 @@ while (p->control_to_send) usleep(1); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -210,14 +201,8 @@ char *name = data; int res = AST_DEVICE_INVALID; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (!data) { ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return res; } @@ -253,9 +238,6 @@ ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n", SKYPIAX_P_LOG, name); } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return res; } @@ -268,9 +250,6 @@ struct skypiax_pvt *p = c->tech_pvt; int res = 0; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond); switch (cond) { @@ -296,9 +275,6 @@ res = -1; } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return res; } @@ -310,18 +286,12 @@ struct ast_channel *tmp = NULL; char *name = data; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format); if (!data) { ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -372,9 +342,6 @@ WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name); } /* return the newly created channel */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return tmp; } @@ -390,15 +357,9 @@ /* if there is not skypiax pvt why we are here ? */ if (!p) { ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) { char msg_to_skype[1024]; p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED; @@ -457,26 +418,15 @@ /* set the channel state to DOWN, eg. available, not in active use */ if (ast_setstate(c, SKYPIAX_STATE_DOWN)) { ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug) - DEBUGA_PBX("Hanged Up\n", SKYPIAX_P_LOG); /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */ if (skypiax_restart_monitor()) { ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -487,9 +437,6 @@ struct skypiax_pvt *p = c->tech_pvt; int res; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* whle ringing, we just wait, the skype thread will answer */ while (p->interface_state == SKYPIAX_STATE_RING) { usleep(10000); //10msec @@ -498,13 +445,9 @@ ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state); res = -1; } else { - if (option_debug) DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG); res = 0; } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return res; } @@ -512,15 +455,9 @@ int skypiax_senddigit_begin(struct ast_channel *c, char digit) { struct skypiax_pvt *p = c->tech_pvt; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -528,9 +465,6 @@ { struct skypiax_pvt *p = c->tech_pvt; char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration); @@ -538,9 +472,6 @@ skypiax_skype_write(p, msg_to_skype); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } #else /* ASTERISK_VERSION_1_4 */ @@ -549,18 +480,12 @@ struct skypiax_pvt *p = c->tech_pvt; char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit); skypiax_skype_write(p, msg_to_skype); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -576,9 +501,6 @@ short *buf; int samples; - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* if there are control frames queued to be sent by skypiax_queue_control, send it the first */ //TODO maybe better a real queue? @@ -605,9 +527,6 @@ /* if the call is not active (ie: answered), do not send audio frames, they would pile up in a lag queue */ if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return &f; } @@ -632,10 +551,6 @@ skypiax_sound_boost(&f, p->capture_boost); } - if (option_debug > 100) { - DEBUGA_SOUND("samples=%d\n", SKYPIAX_P_LOG, samples); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return &f; } @@ -650,20 +565,13 @@ char *stringp = NULL; int status; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if ((c->_state != SKYPIAX_STATE_DOWN) && (c->_state != SKYPIAX_STATE_RESERVED)) { ERRORA("skypiax_call called on %s, neither down nor reserved\n", SKYPIAX_P_LOG, c->name); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug > 1) DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest, timeout); @@ -674,14 +582,10 @@ if (!where) { ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n", SKYPIAX_P_LOG, idest); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1); - if (option_debug > 1) DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr); @@ -689,20 +593,13 @@ status = skypiax_skype_call(p, dstr, timeout); if (status) { WARNINGA("skypiax_call dialing failed: %d!\n", SKYPIAX_P_LOG, status); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug > 1) DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr); ast_setstate(p->owner, SKYPIAX_STATE_DIALING); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -731,13 +628,7 @@ struct skypiax_pvt *p = c->tech_pvt; int sent; - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } if (p->playback_boost) @@ -746,10 +637,6 @@ sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen); //skypiax_sound_write(p, f); - if (option_debug > 100) { - DEBUGA_SOUND("sent=%d\n", SKYPIAX_P_LOG, sent); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -759,29 +646,17 @@ { struct skypiax_pvt *p = newchan->tech_pvt; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (!p) { ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } if (p->owner != oldchan) { ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } p->owner = newchan; - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -789,9 +664,6 @@ { struct ast_channel *tmp; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* alloc a generic channel struct */ #ifndef ASTERISK_VERSION_1_4 tmp = ast_channel_alloc(1); @@ -858,9 +730,6 @@ ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG); //ast_dsp_free(p->dsp); ast_channel_free(tmp); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } /* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */ @@ -869,9 +738,6 @@ if (ast_pbx_start(tmp)) { ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name); ast_channel_free(tmp); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } } @@ -893,15 +759,9 @@ ast_update_use_count(); /* return the newly created channel */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return tmp; } ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -927,10 +787,6 @@ struct ast_flags config_flags = { 0 }; #endif /* ASTERISK_VERSION_1_6 */ - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - ast_log(LOG_DEBUG, "ENTERING FUNC\n"); - } #if defined(WANT_SKYPE_X11) || defined(__CYGWIN__) #ifndef __CYGWIN__ if (!XInitThreads()) @@ -949,9 +805,6 @@ i = ast_channel_register(&skypiax_tech); if (i < 0) { ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } /* load skypiax.conf config file */ @@ -984,9 +837,6 @@ /* if error, unload config from memory and return */ ast_config_destroy(cfg); ast_channel_unregister(&skypiax_tech); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } /* do it for each category described in config */ @@ -997,9 +847,6 @@ } else { ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG); ast_channel_unregister(&skypiax_tech); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } #ifndef ASTERISK_VERSION_1_6 @@ -1008,14 +855,8 @@ /* start to monitor the interfaces (skypiax_iflist) for the first time */ if (skypiax_restart_monitor()) { ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -1034,9 +875,6 @@ struct skypiax_pvt *p = NULL, *p2 = NULL; int res; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* unregister our channel type with Asterisk */ ast_channel_unregister(&skypiax_tech); @@ -1060,9 +898,6 @@ && (skypiax_monitor_thread != AST_PTHREADT_STOP)) { if (pthread_cancel(skypiax_monitor_thread)) { ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } if (pthread_kill(skypiax_monitor_thread, SIGURG)) { @@ -1071,9 +906,6 @@ #ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */ if (pthread_join(skypiax_monitor_thread, NULL)) { ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } #endif /* __CYGWIN__ */ @@ -1128,9 +960,6 @@ sleep(5); /* without this pause, for some unknown (to me) reason it crashes on cygwin */ #endif /* __CYGWIN__ */ NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -1143,9 +972,6 @@ { int res; static struct skypiax_pvt *p = &skypiax_log_struct; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* lock the skypiax_usecnt lock */ LOKKA(&skypiax_usecnt_lock); /* retrieve the skypiax_usecnt */ @@ -1153,9 +979,6 @@ /* unlock the skypiax_usecnt lock */ UNLOCKA(&skypiax_usecnt_lock); /* return the skypiax_usecnt */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return res; } @@ -1166,13 +989,6 @@ */ char *description() { - static struct skypiax_pvt *p = &skypiax_log_struct; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return (char *) skypiax_desc; } @@ -1184,16 +1000,9 @@ char *key() { struct skypiax_pvt *p = NULL; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - if (option_debug) NOTICA("Returning Key\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return ASTERISK_GPL_KEY; } @@ -1228,10 +1037,6 @@ /* alloc memory for PVT */ tmp = malloc(sizeof(struct skypiax_pvt)); if (tmp == NULL) { /* fail */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - ast_log(LOG_DEBUG, "EXITING FUNC\n"); - } return NULL; } /* clear memory for PVT */ @@ -1399,9 +1204,6 @@ if (res == -1) { ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG); /* we failed, free the PVT */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } free(tmp); return NULL; } @@ -1421,7 +1223,6 @@ tmp->skype_thread = AST_PTHREADT_NULL; if (tmp->skype) { - if (option_debug > 1) ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n", (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); @@ -1429,21 +1230,14 @@ if (ast_pthread_create (&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } free(tmp); return NULL; } #else /* __CYGWIN__ */ #ifdef WANT_SKYPE_X11 - if (option_debug > 1) ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]); if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } free(tmp); return NULL; } @@ -1452,13 +1246,9 @@ usleep(100000); //0.1 sec if( tmp->skype_thread == AST_PTHREADT_NULL){ ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } free(tmp); return NULL; } - if (option_debug > 1) ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n", (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); @@ -1516,9 +1306,6 @@ /* return the newly created skypiax_pvt */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } return tmp; } @@ -1527,14 +1314,8 @@ { static struct skypiax_pvt *p = &skypiax_log_struct; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } /* If we're supposed to be stopped -- stay stopped */ if (skypiax_monitor_thread == AST_PTHREADT_STOP) { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } LOKKA(&skypiax_monlock); @@ -1542,9 +1323,6 @@ if (skypiax_monitor_thread == pthread_self()) { UNLOCKA(&skypiax_monlock); ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } /* if the monitor thread exists */ @@ -1556,16 +1334,10 @@ if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) { UNLOCKA(&skypiax_monlock); ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } } UNLOCKA(&skypiax_monlock); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -1582,14 +1354,8 @@ struct timeval to; time_t now_timestamp; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -1657,9 +1423,6 @@ continue; else { ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno)); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } } @@ -1694,9 +1457,6 @@ pthread_testcancel(); } /* Never reached */ - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -1712,12 +1472,6 @@ int skypiax_sound_init(struct skypiax_pvt *p) { - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return skypiax_skypeaudio_init(p); } @@ -1733,14 +1487,8 @@ int skypiax_sound_shutdown(struct skypiax_pvt *p) { - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } //return skypiax_portaudio_shutdown(p); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } @@ -1750,14 +1498,8 @@ struct ast_frame *f = NULL; int res; - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } res = skypiax_skypeaudio_read(p); f = &p->read_frame; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return f; } @@ -1766,13 +1508,7 @@ { int ret = -1; - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } ret = skypiax_skypeaudio_write(p, f); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return ret; } @@ -1785,16 +1521,10 @@ struct skypiax_pvt *p = data; int res; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p); if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -1804,7 +1534,6 @@ if (p->skype) { res = skypiax_skype_read(p); if (res == CALLFLOW_INCOMING_HANGUP) { - if (option_debug) DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); if (p->owner) { pthread_testcancel(); @@ -1814,9 +1543,6 @@ } } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -1835,14 +1561,8 @@ { struct skypiax_pvt *p = NULL; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (sscanf(s, "%lf", boost) != 1) { ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return; } if (*boost < -BOOST_MAX) { @@ -1853,7 +1573,6 @@ *boost = BOOST_MAX; } *boost = exp(log(10) * *boost / 20) * BOOST_SCALE; - if (option_debug > 1) DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost); } @@ -1863,38 +1582,23 @@ struct skypiax_pvt *skypiax_console_find_desc(char *dev) { struct skypiax_pvt *p = NULL; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next); if (p == NULL) WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return p; } int skypiax_console_playback_boost(int fd, int argc, char *argv[]) { struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (argc > 2) { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SHOWUSAGE; } if (!p) { ast_cli(fd, "No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -1911,30 +1615,18 @@ 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE))); } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } int skypiax_console_capture_boost(int fd, int argc, char *argv[]) { struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (argc > 2) { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SHOWUSAGE; } if (!p) { ast_cli(fd, "No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -1951,9 +1643,6 @@ 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE))); } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -1961,36 +1650,21 @@ { struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (argc != 1) { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SHOWUSAGE; } if (!p) { ast_cli(fd, "No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } if (!p->owner) { ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n", skypiax_console_active); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_FAILURE; } if (p->owner) ast_queue_hangup(p->owner); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -1999,21 +1673,12 @@ char *s = NULL; struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (argc != 2) { - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SHOWUSAGE; } if (!p) { ast_cli(fd, "No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -2027,9 +1692,6 @@ f.subclass = s[i]; ast_queue_frame(p->owner, &f); } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } else ast_cli(fd, @@ -2037,9 +1699,6 @@ skypiax_console_active); if (s) free(s); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } int skypiax_console_set_active(int fd, int argc, char *argv[]) @@ -2093,9 +1752,6 @@ if (ast_pthread_create (&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) { ERRORA("Unable to start tcp_srv_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_srv_thread thread.\n", SKYPIAX_P_LOG); @@ -2105,9 +1761,6 @@ 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); @@ -2230,14 +1883,8 @@ { int sent; - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } int skypiax_console_skype(int fd, int argc, char *argv[]) @@ -2254,17 +1901,8 @@ "No \"current\" console for skypiax_skype, please enter 'help console'\n"); return RESULT_SUCCESS; } - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } if (!p->skype) { ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -2285,9 +1923,6 @@ break; } skypiax_skype_write(p, skype_msg); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return RESULT_SUCCESS; } @@ -2370,7 +2005,6 @@ } else { snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); } - if (option_debug) NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); time(&t); ast_copy_string(date, ctime(&t), sizeof(date)); @@ -2382,14 +2016,12 @@ if (p->phonebook_writing_fp) { if (add_to_skypiax_dir_conf) { - if (option_debug) NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); fprintf(p->phonebook_writing_fp, ";!\n"); fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); fprintf(p->phonebook_writing_fp, ";!\n"); } else { - if (option_debug) NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); fprintf(p->phonebook_writing_fp, ";!\n"); fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); From gmaruzz at freeswitch.org Mon Feb 9 09:23:01 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 11:23:01 -0600 Subject: [Freeswitch-branches] [commit] r11709 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 11:23:01 2009 New Revision: 11709 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 11:23:01 2009 @@ -25,7 +25,6 @@ switch_mutex_t *mutex; } globals; -int option_debug = 100; switch_endpoint_interface_t *skypiax_endpoint_interface; switch_memory_pool_t *skypiax_module_pool = NULL; int running = 0; @@ -95,7 +94,6 @@ void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); tech_pvt->read_frame.data = tech_pvt->databuf; tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf); switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, @@ -111,7 +109,6 @@ DEBUGA_SKYPE("skypiax_codec SUCCESS\n", SKYPIAX_P_LOG); } - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } /* @@ -585,7 +582,6 @@ int res; int forever = 1; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("In skypiax_signaling_thread_func: started, p=%p\n", SKYPIAX_P_LOG, (void *) tech_pvt); @@ -623,7 +619,6 @@ memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str)); } } - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } @@ -971,7 +966,6 @@ skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG); if(running) /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:23:01 2009 @@ -11,10 +11,10 @@ extern switch_endpoint_interface_t *skypiax_endpoint_interface; #endif /* ASTERISK */ -extern int option_debug; extern int running; /*************************************/ +/* suspicious globals FIXME */ #ifdef WIN32 DWORD win32_dwThreadId; #else @@ -45,9 +45,6 @@ short kill_cli_buff[SAMPLES_PER_FRAME]; short totalbuf[SAMPLES_PER_FRAME]; - if (option_debug > 100) { - DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG); - } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ @@ -55,17 +52,11 @@ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { ERRORA("bind Error\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); @@ -183,9 +174,6 @@ DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(s); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -208,9 +196,6 @@ unsigned int sin_size; #endif /* WIN32 */ - if (option_debug > 100) { - DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG); - } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ @@ -218,17 +203,11 @@ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { ERRORA("bind Error\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } skypiax_close_socket(s); return NULL; } @@ -321,9 +300,6 @@ DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG); skypiax_close_socket(s); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return NULL; } @@ -391,9 +367,6 @@ struct timeval to; #endif /* WIN32 */ - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } memset(read_from_pipe, 0, 4096); memset(messaggio, 0, 4096); @@ -442,14 +415,10 @@ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", SKYPIAX_P_LOG, messaggio); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } tech_pvt->interface_state = SKYPIAX_STATE_DOWN; return CALLFLOW_INCOMING_HANGUP; } else { @@ -487,14 +456,10 @@ if (!strcasecmp(messaggio, "ERROR")) { ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } tech_pvt->interface_state = SKYPIAX_STATE_DOWN; return CALLFLOW_INCOMING_HANGUP; } else { @@ -596,7 +561,6 @@ where = strsep(stringp, " "); - if (option_debug > 101) 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"); @@ -643,7 +607,6 @@ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { if (strcasecmp(id, tech_pvt->skype_call_id)) { strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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); @@ -674,7 +637,6 @@ skypiax_sleep(10000); sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); skypiax_skype_write(tech_pvt, msg_to_skype); - if (option_debug) DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, id); strncpy(tech_pvt->skype_call_id, id, @@ -710,14 +672,10 @@ } else if (!strcasecmp(value, "FINISHED")) { //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; return CALLFLOW_INCOMING_HANGUP; } else { @@ -726,16 +684,12 @@ } else if (!strcasecmp(value, "CANCELLED")) { tech_pvt->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); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } tech_pvt->interface_state = SKYPIAX_STATE_DOWN; return CALLFLOW_INCOMING_HANGUP; } else { @@ -743,22 +697,17 @@ } } else if (!strcasecmp(value, "FAILED")) { tech_pvt->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); tech_pvt->skype_call_id[0] = '\0'; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return CALLFLOW_INCOMING_HANGUP; } else if (!strcasecmp(value, "REFUSED")) { if (!strcasecmp(id, tech_pvt->skype_call_id)) { /* this is the id of the call we are in, probably we generated it */ tech_pvt->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); @@ -766,9 +715,6 @@ sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_DOWN; tech_pvt->skype_call_id[0] = '\0'; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return CALLFLOW_INCOMING_HANGUP; } else { /* we're here because were us that refused an incoming call */ @@ -825,19 +771,12 @@ } } - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; } int skypiax_skype_senddigit(private_t * tech_pvt, char digit) { char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); @@ -845,9 +784,6 @@ skypiax_skype_write(tech_pvt, msg_to_skype); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -855,9 +791,6 @@ { char msg_to_skype[1024]; - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } skypiax_sleep(5000); DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); skypiax_skype_write(tech_pvt, "SET AGC OFF"); @@ -869,9 +802,6 @@ if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) { ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } return 0; @@ -988,11 +918,7 @@ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } sprintf(acInputRow, "%s", msg_to_skype); - if (option_debug > 100) DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow); /* send command to skype */ oCopyData.dwData = 0; @@ -1006,16 +932,10 @@ ERRORA ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } } - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -1319,24 +1239,15 @@ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } SkypiaxHandles = &tech_pvt->SkypiaxHandles; if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) { ERRORA ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n", SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return -1; } - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } return 0; } @@ -1407,7 +1318,6 @@ Window root = -1; Window win = -1; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); if (!strlen(tech_pvt->X11_display)) strcpy(tech_pvt->X11_display, getenv("DISPLAY")); @@ -1455,7 +1365,6 @@ ERRORA ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); running = 0; return NULL; } @@ -1465,7 +1374,6 @@ ERRORA ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); running = 0; return NULL; } @@ -1517,7 +1425,6 @@ running = 0; return NULL; } - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); running = 0; return NULL; From gmaruzz at freeswitch.org Mon Feb 9 09:25:07 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 11:25:07 -0600 Subject: [Freeswitch-branches] [commit] r11710 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 11:25:07 2009 New Revision: 11710 Log: skypiax: cleaning on Visual C Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 11:25:07 2009 @@ -948,8 +948,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { - private_t *tech_pvt = NULL; //for logging - skypiax_module_pool = pool; memset(&globals, '\0', sizeof(globals)); From gmaruzz at freeswitch.org Mon Feb 9 09:34:30 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 11:34:30 -0600 Subject: [Freeswitch-branches] [commit] r11711 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 11:34:30 2009 New Revision: 11711 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:34:30 2009 @@ -303,34 +303,6 @@ return NULL; } -int skypiax_skypeaudio_init(private_t * tech_pvt) -{ - -#if defined(WIN32) && !defined(__CYGWIN__) - switch_status_t rv; - rv = - switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], - skypiax_module_pool); - rv = - switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1], - skypiax_module_pool); -#else /* WIN32 */ - if (pipe(tech_pvt->audiopipe)) { - fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK); - } - if (pipe(tech_pvt->audioskypepipe)) { - fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK); - } -#endif /* WIN32 */ - -/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */ - tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; - - return 0; -} - int skypiax_skypeaudio_read(private_t * tech_pvt) { unsigned int samples; @@ -843,7 +815,17 @@ return res; } - +int skypiax_skypeaudio_init(private_t * tech_pvt) +{ + switch_status_t rv; + rv = + switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], + skypiax_module_pool); + rv = + switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1], + skypiax_module_pool); + return 0; +} #else /* WIN32 */ int skypiax_pipe_read(int pipe, short *buf, int howmany) { @@ -863,6 +845,22 @@ return res; } +int skypiax_skypeaudio_init(private_t * tech_pvt) +{ + if (pipe(tech_pvt->audiopipe)) { + fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK); + fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK); + } + if (pipe(tech_pvt->audioskypepipe)) { + fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK); + fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK); + } + +/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */ + tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0]; + + return 0; +} #endif /* WIN32 */ From gmaruzz at freeswitch.org Mon Feb 9 09:35:00 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 11:35:00 -0600 Subject: [Freeswitch-branches] [commit] r11712 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 11:35:00 2009 New Revision: 11712 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:35:00 2009 @@ -230,13 +230,13 @@ if (!running) break; - fdselect = fd; + fdselect = fd; FD_ZERO(&fs); FD_SET(fdselect, &fs); to.tv_usec = 2000000; //2000 msec to.tv_sec = 0; - rt = select(fdselect + 1, NULL, &fs, NULL, &to); + rt = select(fdselect + 1, NULL, &fs, NULL, &to); if (rt > 0) { @@ -246,7 +246,7 @@ SAMPLES_PER_FRAME * sizeof(short)); if (got != SAMPLES_PER_FRAME * sizeof(short)) { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); + SAMPLES_PER_FRAME * sizeof(short)); } if (got == SAMPLES_PER_FRAME * sizeof(short)) { @@ -284,7 +284,7 @@ } else { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); + SAMPLES_PER_FRAME * sizeof(short)); } } else { if (rt) @@ -307,17 +307,19 @@ { unsigned int samples; - samples = - skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short)); - - if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - if (samples) - WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); - return 0; - } else { - /* A real frame */ - tech_pvt->read_frame.datalen = samples; - } + samples = + skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, + SAMPLES_PER_FRAME * sizeof(short)); + + if (samples != SAMPLES_PER_FRAME * sizeof(short)) { + if (samples) + WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, + SAMPLES_PER_FRAME * sizeof(short)); + return 0; + } else { + /* A real frame */ + tech_pvt->read_frame.datalen = samples; + } return 1; } @@ -339,7 +341,6 @@ struct timeval to; #endif /* WIN32 */ - memset(read_from_pipe, 0, 4096); memset(messaggio, 0, 4096); memset(messaggio_2, 0, 4096); @@ -387,7 +388,7 @@ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", SKYPIAX_P_LOG, messaggio); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { @@ -428,7 +429,7 @@ if (!strcasecmp(messaggio, "ERROR")) { ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { @@ -533,9 +534,9 @@ where = strsep(stringp, " "); - 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"); + 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(tech_pvt->callid_number, value, @@ -579,9 +580,9 @@ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { if (strcasecmp(id, tech_pvt->skype_call_id)) { strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE - ("We called a Skype contact and he answered us on skype_call: %s.\n", - SKYPIAX_P_LOG, id); + DEBUGA_SKYPE + ("We called a Skype contact and he answered us on skype_call: %s.\n", + SKYPIAX_P_LOG, id); } } @@ -609,8 +610,8 @@ skypiax_sleep(10000); sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); skypiax_skype_write(tech_pvt, msg_to_skype); - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", - SKYPIAX_P_LOG, id); + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", + SKYPIAX_P_LOG, id); strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); } else { @@ -644,7 +645,7 @@ } else if (!strcasecmp(value, "FINISHED")) { //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { @@ -656,9 +657,9 @@ } else if (!strcasecmp(value, "CANCELLED")) { tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", - SKYPIAX_P_LOG, id); + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", + SKYPIAX_P_LOG, id); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { @@ -669,9 +670,9 @@ } } else if (!strcasecmp(value, "FAILED")) { tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", - SKYPIAX_P_LOG, id); + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", + SKYPIAX_P_LOG, id); tech_pvt->skype_call_id[0] = '\0'; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_DOWN; @@ -680,9 +681,9 @@ if (!strcasecmp(id, tech_pvt->skype_call_id)) { /* this is the id of the call we are in, probably we generated it */ tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", - SKYPIAX_P_LOG, id); + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", + SKYPIAX_P_LOG, id); strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_DOWN; @@ -708,7 +709,7 @@ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port); skypiax_skype_write(tech_pvt, msg_to_skype); @@ -815,6 +816,7 @@ return res; } + int skypiax_skypeaudio_init(private_t * tech_pvt) { switch_status_t rv; @@ -845,6 +847,7 @@ return res; } + int skypiax_skypeaudio_init(private_t * tech_pvt) { if (pipe(tech_pvt->audiopipe)) { @@ -863,7 +866,6 @@ } #endif /* WIN32 */ - #ifdef WIN32 enum { @@ -917,7 +919,7 @@ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); sprintf(acInputRow, "%s", msg_to_skype); - DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow); + DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow); /* send command to skype */ oCopyData.dwData = 0; oCopyData.lpData = acInputRow; @@ -1105,7 +1107,6 @@ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; } - void *skypiax_do_skypeapi_thread_func(void *obj) { private_t *tech_pvt = obj; @@ -1250,7 +1251,6 @@ } - int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles) { Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True); @@ -1316,7 +1316,6 @@ Window root = -1; Window win = -1; - if (!strlen(tech_pvt->X11_display)) strcpy(tech_pvt->X11_display, getenv("DISPLAY")); @@ -1428,5 +1427,3 @@ } #endif // WIN32 - - From gmaruzz at freeswitch.org Mon Feb 9 10:10:52 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 12:10:52 -0600 Subject: [Freeswitch-branches] [commit] r11714 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 12:10:52 2009 New Revision: 11714 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:10:52 2009 @@ -327,53 +327,32 @@ { char read_from_pipe[4096]; - char messaggio[4096]; - char messaggio_2[4096]; + char message[4096]; + char message_2[4096]; char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where; char **stringp = NULL; - int rt; int a; unsigned int howmany; unsigned int i; -#ifndef WIN32 - int fdselect; - fd_set fs; - struct timeval to; -#endif /* WIN32 */ memset(read_from_pipe, 0, 4096); - memset(messaggio, 0, 4096); - memset(messaggio_2, 0, 4096); + memset(message, 0, 4096); + memset(message_2, 0, 4096); -#ifdef WIN32 - rt = 1; -#else /* WIN32 */ - fdselect = tech_pvt->SkypiaxHandles.fdesc[0]; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //500 msec - to.tv_sec = 0; - rt = select(fdselect + 1, &fs, NULL, NULL, &to); -#endif /* WIN32 */ - - if (rt > 0) { - if (tech_pvt->SkypiaxHandles.fdesc[0]) { - howmany = sizeof(read_from_pipe); howmany = skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, - howmany); + sizeof(read_from_pipe)); a = 0; for (i = 0; i < howmany; i++) { - messaggio[a] = read_from_pipe[i]; + message[a] = read_from_pipe[i]; a++; if (read_from_pipe[i] == '\0') { - //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); - DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio); + DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message); - if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified, + if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified, just authorized */ DEBUGA_SKYPE ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", @@ -384,9 +363,9 @@ return 0; } - if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { + if (!strncasecmp(message, "ERROR 92 CALL", 12)) { ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", - SKYPIAX_P_LOG, messaggio); + SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; @@ -399,35 +378,35 @@ } } - strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1); + strncpy(message_2, message, sizeof(message) - 1); - buf = messaggio; + buf = message; stringp = &buf; where = strsep(stringp, " "); if (!where) { - WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio); + WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); } - if (!strcasecmp(messaggio, "#333")) { - /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG, - * messaggio_2, &messaggio_2[11]); */ + if (!strcasecmp(message, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[11]); */ memset(tech_pvt->skype_friends, 0, 4096); - strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095); + strncpy(tech_pvt->skype_friends, &message_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]); */ + if (!strcasecmp(message, "#222")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ memset(tech_pvt->skype_fullname, 0, 512); - strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511); + strncpy(tech_pvt->skype_fullname, &message_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]); */ + if (!strcasecmp(message, "#765")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ memset(tech_pvt->skype_displayname, 0, 512); - strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511); + strncpy(tech_pvt->skype_displayname, &message_2[10], 511); } - if (!strcasecmp(messaggio, "ERROR")) { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); + if (!strcasecmp(message, "ERROR")) { + ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; @@ -439,7 +418,7 @@ tech_pvt->interface_state = SKYPIAX_STATE_DOWN; } } - if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) { + if (!strcasecmp(message, "CURRENTUSERHANDLE")) { strncpy(obj, where, sizeof(obj) - 1); where = strsep(stringp, " "); @@ -449,12 +428,12 @@ if (!strcasecmp(id, tech_pvt->skype_user)) { tech_pvt->SkypiaxHandles.api_connected = 1; DEBUGA_SKYPE - ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user); + ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", + SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user); } } - if (!strcasecmp(messaggio, "USER")) { + if (!strcasecmp(message, "USER")) { strncpy(obj, where, sizeof(obj) - 1); where = strsep(stringp, " "); @@ -467,8 +446,8 @@ if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop); + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); //FIXME: TODO: allow authorization based on config param sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); @@ -476,7 +455,7 @@ } } - if (!strcasecmp(messaggio, "MESSAGE")) { + if (!strcasecmp(message, "MESSAGE")) { strncpy(obj, where, sizeof(obj) - 1); where = strsep(stringp, " "); @@ -496,8 +475,8 @@ if (!strcasecmp(value, "RECEIVED")) { char msg_to_skype[256]; DEBUGA_SKYPE - ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop, value); + ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value); //FIXME: TODO: allow authorization based on config param sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); @@ -506,8 +485,8 @@ } else if (!strcasecmp(prop, "BODY")) { char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop); + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); //FIXME: TODO: on config param ??? sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); @@ -516,7 +495,7 @@ } - if (!strcasecmp(messaggio, "CALL")) { + if (!strcasecmp(message, "CALL")) { strncpy(obj, where, sizeof(obj) - 1); @@ -535,8 +514,8 @@ where = strsep(stringp, " "); 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"); + ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); if (!strcasecmp(prop, "PARTNER_HANDLE")) { strncpy(tech_pvt->callid_number, value, @@ -741,8 +720,6 @@ } //message end } //read_from_pipe - } - } return 0; } From gmaruzz at freeswitch.org Mon Feb 9 10:26:31 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 12:26:31 -0600 Subject: [Freeswitch-branches] [commit] r11715 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 12:26:31 2009 New Revision: 11715 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:26:31 2009 @@ -352,8 +352,7 @@ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message); - if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified, - just authorized */ + if (!strcasecmp(message, "ERROR 68")) { DEBUGA_SKYPE ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", SKYPIAX_P_LOG); @@ -386,25 +385,6 @@ if (!where) { WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); } - - if (!strcasecmp(message, "#333")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[11]); */ - memset(tech_pvt->skype_friends, 0, 4096); - strncpy(tech_pvt->skype_friends, &message_2[11], 4095); - } - if (!strcasecmp(message, "#222")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_fullname, 0, 512); - strncpy(tech_pvt->skype_fullname, &message_2[10], 511); - } - if (!strcasecmp(message, "#765")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_displayname, 0, 512); - strncpy(tech_pvt->skype_displayname, &message_2[10], 511); - } if (!strcasecmp(message, "ERROR")) { ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; @@ -716,6 +696,26 @@ } //CALL + /* the "numbered" messages that follows are used by the directory application, not yet ported */ + if (!strcasecmp(message, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[11]); */ + memset(tech_pvt->skype_friends, 0, 4096); + strncpy(tech_pvt->skype_friends, &message_2[11], 4095); + } + if (!strcasecmp(message, "#222")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_fullname, 0, 512); + strncpy(tech_pvt->skype_fullname, &message_2[10], 511); + } + if (!strcasecmp(message, "#765")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_displayname, 0, 512); + strncpy(tech_pvt->skype_displayname, &message_2[10], 511); + } + a = 0; } //message end } //read_from_pipe From gmaruzz at freeswitch.org Mon Feb 9 10:26:49 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 12:26:49 -0600 Subject: [Freeswitch-branches] [commit] r11716 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 12:26:48 2009 New Revision: 11716 Log: skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:26:48 2009 @@ -339,387 +339,380 @@ memset(message, 0, 4096); memset(message_2, 0, 4096); - howmany = - skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, - sizeof(read_from_pipe)); - - a = 0; - for (i = 0; i < howmany; i++) { - message[a] = read_from_pipe[i]; - a++; - - if (read_from_pipe[i] == '\0') { + howmany = + skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe, + sizeof(read_from_pipe)); + + a = 0; + for (i = 0; i < howmany; i++) { + message[a] = read_from_pipe[i]; + a++; + + if (read_from_pipe[i] == '\0') { + + DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message); + + if (!strcasecmp(message, "ERROR 68")) { + DEBUGA_SKYPE + ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", + SKYPIAX_P_LOG); + skypiax_sleep(1000000); + skypiax_skype_write(tech_pvt, "PROTOCOL 6"); + skypiax_sleep(10000); + return 0; + } - DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message); + if (!strncasecmp(message, "ERROR 92 CALL", 12)) { + ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", + SKYPIAX_P_LOG, message); + tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + tech_pvt->skype_call_id[0] = '\0'; + + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } - if (!strcasecmp(message, "ERROR 68")) { - DEBUGA_SKYPE - ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", - SKYPIAX_P_LOG); - skypiax_sleep(1000000); - skypiax_skype_write(tech_pvt, "PROTOCOL 6"); - skypiax_sleep(10000); - return 0; - } + strncpy(message_2, message, sizeof(message) - 1); - if (!strncasecmp(message, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", - SKYPIAX_P_LOG, message); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; + buf = message; + stringp = &buf; + where = strsep(stringp, " "); + if (!where) { + WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); + } + if (!strcasecmp(message, "ERROR")) { + ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); + tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + tech_pvt->skype_call_id[0] = '\0'; + + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } + if (!strcasecmp(message, "CURRENTUSERHANDLE")) { + strncpy(obj, where, sizeof(obj) - 1); - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } + where = strsep(stringp, " "); - strncpy(message_2, message, sizeof(message) - 1); + strncpy(id, where, sizeof(id) - 1); - buf = message; - stringp = &buf; - where = strsep(stringp, " "); - if (!where) { - WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); - } - if (!strcasecmp(message, "ERROR")) { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; + if (!strcasecmp(id, tech_pvt->skype_user)) { + tech_pvt->SkypiaxHandles.api_connected = 1; + DEBUGA_SKYPE + ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", + SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user); + } + } - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } - if (!strcasecmp(message, "CURRENTUSERHANDLE")) { - strncpy(obj, where, sizeof(obj) - 1); + if (!strcasecmp(message, "USER")) { + strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); + where = strsep(stringp, " "); - strncpy(id, where, sizeof(id) - 1); + strncpy(id, where, sizeof(id) - 1); - if (!strcasecmp(id, tech_pvt->skype_user)) { - tech_pvt->SkypiaxHandles.api_connected = 1; - DEBUGA_SKYPE - ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", - SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user); - } - } + where = strsep(stringp, " "); - if (!strcasecmp(message, "USER")) { - strncpy(obj, where, sizeof(obj) - 1); + strncpy(prop, where, sizeof(prop) - 1); - where = strsep(stringp, " "); + if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); - strncpy(id, where, sizeof(id) - 1); + //FIXME: TODO: allow authorization based on config param + sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } - where = strsep(stringp, " "); + if (!strcasecmp(message, "MESSAGE")) { + strncpy(obj, where, sizeof(obj) - 1); - strncpy(prop, where, sizeof(prop) - 1); + where = strsep(stringp, " "); - if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop); + strncpy(id, where, sizeof(id) - 1); - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } - } + where = strsep(stringp, " "); - if (!strcasecmp(message, "MESSAGE")) { - strncpy(obj, where, sizeof(obj) - 1); + strncpy(prop, where, sizeof(prop) - 1); - where = strsep(stringp, " "); + if (!strcasecmp(prop, "STATUS")) { - strncpy(id, where, sizeof(id) - 1); + where = strsep(stringp, " "); - where = strsep(stringp, " "); + strncpy(value, where, sizeof(value) - 1); - strncpy(prop, where, sizeof(prop) - 1); + if (!strcasecmp(value, "RECEIVED")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value); + + //FIXME: TODO: allow authorization based on config param + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } else if (!strcasecmp(prop, "BODY")) { + char msg_to_skype[256]; - if (!strcasecmp(prop, "STATUS")) { + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); - where = strsep(stringp, " "); + //FIXME: TODO: on config param ??? + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } - strncpy(value, where, sizeof(value) - 1); + } - if (!strcasecmp(value, "RECEIVED")) { - char msg_to_skype[256]; - DEBUGA_SKYPE - ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop, value); + if (!strcasecmp(message, "CALL")) { - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } - } else if (!strcasecmp(prop, "BODY")) { - char msg_to_skype[256]; + strncpy(obj, where, sizeof(obj) - 1); - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop); + where = strsep(stringp, " "); - //FIXME: TODO: on config param ??? - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } + strncpy(id, where, sizeof(id) - 1); - } + where = strsep(stringp, " "); - if (!strcasecmp(message, "CALL")) { + strncpy(prop, where, sizeof(prop) - 1); - strncpy(obj, where, sizeof(obj) - 1); + where = strsep(stringp, " "); - where = strsep(stringp, " "); + strncpy(value, where, sizeof(value) - 1); - strncpy(id, where, sizeof(id) - 1); + where = strsep(stringp, " "); - where = strsep(stringp, " "); + DEBUGA_SKYPE + ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); - strncpy(prop, where, sizeof(prop) - 1); + if (!strcasecmp(prop, "PARTNER_HANDLE")) { + strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_number); + return CALLFLOW_INCOMING_RING; + } + if (!strcasecmp(prop, "PARTNER_DISPNAME")) { + snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", + value, where ? " " : "", where ? where : ""); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_name); + } + 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->interface_state = SKYPIAX_STATE_PRERING; + } - where = strsep(stringp, " "); + if (!strcasecmp(prop, "DTMF")) { - strncpy(value, where, sizeof(value) - 1); + DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); - where = strsep(stringp, " "); + dtmf_received(tech_pvt, value); + } + if (!strcasecmp(prop, "FAILUREREASON")) { + 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, tech_pvt->skype_call_id)) { + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE - ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); - - if (!strcasecmp(prop, "PARTNER_HANDLE")) { - strncpy(tech_pvt->callid_number, value, - sizeof(tech_pvt->callid_number) - 1); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_number); - return CALLFLOW_INCOMING_RING; - } - if (!strcasecmp(prop, "PARTNER_DISPNAME")) { - snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", - value, where ? " " : "", where ? where : ""); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_name); - } - 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->interface_state = SKYPIAX_STATE_PRERING; - } - - if (!strcasecmp(prop, "DTMF")) { - - DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); + ("We called a Skype contact and he answered us on skype_call: %s.\n", + SKYPIAX_P_LOG, id); + } + } - dtmf_received(tech_pvt, value); - } + if (!strcasecmp(prop, "STATUS")) { - if (!strcasecmp(prop, "FAILUREREASON")) { - 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, tech_pvt->skype_call_id)) { + if (!strcasecmp(value, "RINGING")) { + char msg_to_skype[1024]; + if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { + /* we are not calling out */ + + if (!strlen(tech_pvt->skype_call_id)) { //FIXME + /* we are not inside an active call */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RING; + /* no owner, no active call, let's answer */ + skypiax_skype_write(tech_pvt, "SET AGC OFF"); + skypiax_sleep(10000); + skypiax_skype_write(tech_pvt, "SET AEC OFF"); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, + id); strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + } else { + /* we're owned, we're in a call, let's refuse */ + sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); DEBUGA_SKYPE - ("We called a Skype contact and he answered us on skype_call: %s.\n", + ("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 */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RINGING; + //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + //FIXME ast_queue_control(tech_pvt->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")) { + DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); + + } else if (!strcasecmp(value, "FINISHED")) { + //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; - if (!strcasecmp(prop, "STATUS")) { - - if (!strcasecmp(value, "RINGING")) { - char msg_to_skype[1024]; - if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { - /* we are not calling out */ - - if (!strlen(tech_pvt->skype_call_id)) { //FIXME - /* we are not inside an active call */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RING; - /* no owner, no active call, let's answer */ - skypiax_skype_write(tech_pvt, "SET AGC OFF"); - skypiax_sleep(10000); - skypiax_skype_write(tech_pvt, "SET AEC OFF"); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", - SKYPIAX_P_LOG, id); - strncpy(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->skype_call_id) - 1); - } else { - /* we're owned, we're in a call, let's refuse */ - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(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 */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RINGING; - //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); - strncpy(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->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")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - //FIXME ast_queue_control(tech_pvt->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")) { - DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); - - } else if (!strcasecmp(value, "FINISHED")) { - //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - - } else if (!strcasecmp(value, "CANCELLED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", - SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } else if (!strcasecmp(value, "FAILED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", - SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "REFUSED")) { - if (!strcasecmp(id, tech_pvt->skype_call_id)) { - /* this is the id of the call we are in, probably we generated it */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", - SKYPIAX_P_LOG, id); - strncpy(tech_pvt->skype_call_id, id, - sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - 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")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "UNPLACED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_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_skype_write(tech_pvt, msg_to_skype); - - tech_pvt->skype_callflow = SKYPIAX_STATE_UP; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } - if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); - new_inbound_channel(tech_pvt); - } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); - } + } else if (!strcasecmp(value, "CANCELLED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", + SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; - } else { - WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, - id, value); + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } else if (!strcasecmp(value, "FAILED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", + SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else if (!strcasecmp(value, "REFUSED")) { + if (!strcasecmp(id, tech_pvt->skype_call_id)) { + /* this is the id of the call we are in, probably we generated it */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", + SKYPIAX_P_LOG, id); + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + tech_pvt->skype_call_id[0] = '\0'; + 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); - } - } //STATUS + } + } else if (!strcasecmp(value, "ROUTING")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "UNPLACED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "INPROGRESS")) { + char msg_to_skype[1024]; + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_UP; + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_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); + new_inbound_channel(tech_pvt); + } else { + DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); + outbound_channel_answered(tech_pvt); + } - } //CALL + } else { + WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, + value); - /* the "numbered" messages that follows are used by the directory application, not yet ported */ - if (!strcasecmp(message, "#333")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[11]); */ - memset(tech_pvt->skype_friends, 0, 4096); - strncpy(tech_pvt->skype_friends, &message_2[11], 4095); - } - if (!strcasecmp(message, "#222")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_fullname, 0, 512); - strncpy(tech_pvt->skype_fullname, &message_2[10], 511); - } - if (!strcasecmp(message, "#765")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_displayname, 0, 512); - strncpy(tech_pvt->skype_displayname, &message_2[10], 511); } + } //STATUS - a = 0; - } //message end - } //read_from_pipe + } //CALL + /* the "numbered" messages that follows are used by the directory application, not yet ported */ + if (!strcasecmp(message, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[11]); */ + memset(tech_pvt->skype_friends, 0, 4096); + strncpy(tech_pvt->skype_friends, &message_2[11], 4095); + } + if (!strcasecmp(message, "#222")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_fullname, 0, 512); + strncpy(tech_pvt->skype_fullname, &message_2[10], 511); + } + if (!strcasecmp(message, "#765")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_displayname, 0, 512); + strncpy(tech_pvt->skype_displayname, &message_2[10], 511); + } + + a = 0; + } //message end + } //read_from_pipe return 0; } From gmaruzz at freeswitch.org Mon Feb 9 11:25:19 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 09 Feb 2009 13:25:19 -0600 Subject: [Freeswitch-branches] [commit] r11719 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 9 13:25:18 2009 New Revision: 11719 Log: skypiax: cleaning skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 13:25:18 2009 @@ -1058,13 +1058,16 @@ if (channel) { switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; - DEBUGA_SKYPE("%c DTMF %s\n", SKYPIAX_P_LOG, dtmf.digit, + NOTICA("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, switch_channel_get_name(channel)); switch_mutex_lock(tech_pvt->flag_mutex); + //FIXME: why sometimes DTMFs from here do not seems to be get by FS? switch_channel_queue_dtmf(channel, &dtmf); switch_set_flag(tech_pvt, TFLAG_DTMF); switch_mutex_unlock(tech_pvt->flag_mutex); - } + } else { + WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]); + } switch_core_session_rwunlock(session); return 0; Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 13:25:18 2009 @@ -23,309 +23,8 @@ #endif /* WIN32 */ /*************************************/ -void *skypiax_do_tcp_srv_thread_func(void *obj) -{ - private_t *tech_pvt = obj; - int s; - unsigned int len; - unsigned int i; - unsigned int a; -#if defined(WIN32) && !defined(__CYGWIN__) - int sin_size; -#else /* WIN32 */ - unsigned int sin_size; -#endif /* WIN32 */ - unsigned int fd; - short srv_in[SAMPLES_PER_FRAME]; - short srv_out[SAMPLES_PER_FRAME / 2]; - struct sockaddr_in my_addr; - struct sockaddr_in remote_addr; - int exit = 0; - unsigned int kill_cli_size; - short kill_cli_buff[SAMPLES_PER_FRAME]; - short totalbuf[SAMPLES_PER_FRAME]; - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(tech_pvt->tcp_srv_port); - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - ERRORA("socket Error\n", SKYPIAX_P_LOG); - return NULL; - } - - if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { - ERRORA("bind Error\n", SKYPIAX_P_LOG); - return NULL; - } - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - if (!running) - break; - while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { - - unsigned int fdselect; - int rt; - fd_set fs; - struct timeval to; - - if (!running) - break; - exit = 1; - - fdselect = fd; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //2000 msec - to.tv_sec = 0; - - rt = select(fdselect + 1, &fs, NULL, NULL, &to); - if (rt > 0) { - - len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time - - if (len == 320) { - unsigned int howmany; - - if (SAMPLERATE_SKYPIAX == 8000) { - /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ - a = 0; - for (i = 0; i < len / sizeof(short); i++) { - srv_out[a] = srv_in[i]; - i++; - a++; - } - } else if (SAMPLERATE_SKYPIAX == 16000) { - /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */ - for (i = 0; i < len / sizeof(short); i++) { - srv_out[i] = srv_in[i]; - } - } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); - } - /* if not yet done, let's store the half incoming frame */ - if (!tech_pvt->audiobuf_is_loaded) { - for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { - tech_pvt->audiobuf[i] = srv_out[i]; - } - tech_pvt->audiobuf_is_loaded = 1; - } else { - /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ - for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { - totalbuf[i] = tech_pvt->audiobuf[i]; - } - for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) { - totalbuf[i] = srv_out[a]; - i++; - } - /* send the complete frame through the pipe to our code waiting for incoming audio */ - howmany = - skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf, - SAMPLES_PER_FRAME * sizeof(short)); - if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { - ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, - SAMPLES_PER_FRAME * sizeof(short)); - } - /* done with the stored half frame */ - tech_pvt->audiobuf_is_loaded = 0; - } - - } else if (len == 0) { - DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); - skypiax_sleep(1000); - } else { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; - } - - } else { - if (rt) - ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); - skypiax_sleep(10000); - } - - } - - /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */ - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); - kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); - len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - - DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); - skypiax_close_socket(fd); - if (exit) - break; - } - - DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG); - skypiax_close_socket(s); - return NULL; -} - -void *skypiax_do_tcp_cli_thread_func(void *obj) -{ - private_t *tech_pvt = obj; - int s; - struct sockaddr_in my_addr; - struct sockaddr_in remote_addr; - unsigned int got; - unsigned int len; - unsigned int i; - unsigned int a; - unsigned int fd; - short cli_out[SAMPLES_PER_FRAME * 2]; - short cli_in[SAMPLES_PER_FRAME]; -#ifdef WIN32 - int sin_size; -#else - unsigned int sin_size; -#endif /* WIN32 */ - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(tech_pvt->tcp_cli_port); - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - ERRORA("socket Error\n", SKYPIAX_P_LOG); - return NULL; - } - - if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { - ERRORA("bind Error\n", SKYPIAX_P_LOG); - skypiax_close_socket(s); - return NULL; - } - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - if (!running) - break; - while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { - unsigned int fdselect; - int rt; - fd_set fs; - struct timeval to; - - if (!running) - break; - fdselect = fd; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //2000 msec - to.tv_sec = 0; - - rt = select(fdselect + 1, NULL, &fs, NULL, &to); - - if (rt > 0) { - - /* read from the pipe the audio frame we are supposed to send out */ - got = - skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, - SAMPLES_PER_FRAME * sizeof(short)); - if (got != SAMPLES_PER_FRAME * sizeof(short)) { - WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); - } - - if (got == SAMPLES_PER_FRAME * sizeof(short)) { - if (SAMPLERATE_SKYPIAX == 8000) { - - /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */ - a = 0; - for (i = 0; i < got / sizeof(short); i++) { - cli_out[a] = cli_in[i]; - a++; - cli_out[a] = cli_in[i]; - a++; - } - got = got * 2; - } else if (SAMPLERATE_SKYPIAX == 16000) { - /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */ - for (i = 0; i < got / sizeof(short); i++) { - cli_out[i] = cli_in[i]; - } - } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); - } - - /* send the 16khz frame to the Skype client waiting for incoming audio */ - len = send(fd, (char *) cli_out, got, 0); - - if (len == -1) { - break; - } else if (len != got) { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - skypiax_sleep(1000); - break; - } - - } else { - - WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); - } - } else { - if (rt) - ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); - skypiax_sleep(10000); - } - - } - DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG); - skypiax_close_socket(fd); - break; - } - - DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG); - skypiax_close_socket(s); - return NULL; -} - -int skypiax_skypeaudio_read(private_t * tech_pvt) -{ - unsigned int samples; - - samples = - skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, - SAMPLES_PER_FRAME * sizeof(short)); - - if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - if (samples) - WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, - SAMPLES_PER_FRAME * sizeof(short)); - return 0; - } else { - /* A real frame */ - tech_pvt->read_frame.datalen = samples; - } - return 1; -} - int skypiax_skype_read(private_t * tech_pvt) { - char read_from_pipe[4096]; char message[4096]; char message_2[4096]; @@ -361,9 +60,8 @@ skypiax_sleep(10000); return 0; } - if (!strncasecmp(message, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", + ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n", SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); @@ -376,9 +74,7 @@ tech_pvt->interface_state = SKYPIAX_STATE_DOWN; } } - strncpy(message_2, message, sizeof(message) - 1); - buf = message; stringp = &buf; where = strsep(stringp, " "); @@ -386,7 +82,7 @@ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); } if (!strcasecmp(message, "ERROR")) { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); + WARNINGA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; @@ -400,11 +96,8 @@ } if (!strcasecmp(message, "CURRENTUSERHANDLE")) { strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - strncpy(id, where, sizeof(id) - 1); - if (!strcasecmp(id, tech_pvt->skype_user)) { tech_pvt->SkypiaxHandles.api_connected = 1; DEBUGA_SKYPE @@ -412,309 +105,557 @@ SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user); } } - if (!strcasecmp(message, "USER")) { strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); + strncpy(prop, where, sizeof(prop) - 1); + if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); + //TODO: allow authorization based on config param + sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } + if (!strcasecmp(message, "MESSAGE")) { + strncpy(obj, where, sizeof(obj) - 1); + where = strsep(stringp, " "); + strncpy(id, where, sizeof(id) - 1); + where = strsep(stringp, " "); + strncpy(prop, where, sizeof(prop) - 1); + if (!strcasecmp(prop, "STATUS")) { + where = strsep(stringp, " "); + strncpy(value, where, sizeof(value) - 1); + if (!strcasecmp(value, "RECEIVED")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value); + //TODO: authomatically flag messages as read based on config param + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } else if (!strcasecmp(prop, "BODY")) { + char msg_to_skype[256]; + DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop); + //TODO: authomatically flag messages as read based on config param + sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + } + } + if (!strcasecmp(message, "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, " "); + + DEBUGA_SKYPE + ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", + SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); + + if (!strcasecmp(prop, "PARTNER_HANDLE")) { + strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_number); + return CALLFLOW_INCOMING_RING; + } + if (!strcasecmp(prop, "PARTNER_DISPNAME")) { + snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", + value, where ? " " : "", where ? where : ""); + DEBUGA_SKYPE + ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", + SKYPIAX_P_LOG, id, tech_pvt->callid_name); + } + 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) + tech_pvt->interface_state = SKYPIAX_STATE_PRERING; + } + if (!strcasecmp(prop, "DTMF")) { + NOTICA("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); + dtmf_received(tech_pvt, value); + } + if (!strcasecmp(prop, "FAILUREREASON")) { + DEBUGA_SKYPE + ("Skype 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, tech_pvt->skype_call_id)) { + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 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 (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { + /* we are not calling out */ + if (!strlen(tech_pvt->skype_call_id)) { + /* we are not inside an active call */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RING; + /* no owner, no active call, let's answer */ + skypiax_skype_write(tech_pvt, "SET AGC OFF"); + skypiax_sleep(10000); + skypiax_skype_write(tech_pvt, "SET AEC OFF"); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(10000); + sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, + id); + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + } else { + /* we're owned, we're in a call, let's refuse */ + sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); + skypiax_skype_write(tech_pvt, msg_to_skype); + skypiax_sleep(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 */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; + tech_pvt->interface_state = SKYPIAX_STATE_RINGING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + 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")) { + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } else if (!strcasecmp(value, "CANCELLED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", + SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } else if (!strcasecmp(value, "FAILED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", + SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else if (!strcasecmp(value, "REFUSED")) { + if (!strcasecmp(id, tech_pvt->skype_call_id)) { + /* this is the id of the call we are in, probably we generated it */ + tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", + SKYPIAX_P_LOG, id); + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + tech_pvt->skype_call_id[0] = '\0'; + 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")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "UNPLACED")) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; + tech_pvt->interface_state = SKYPIAX_STATE_DIALING; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "INPROGRESS")) { + char msg_to_skype[1024]; + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_UP; + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_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); + new_inbound_channel(tech_pvt); + } else { + DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); + outbound_channel_answered(tech_pvt); + } + } else { + WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, + value); + } + } //STATUS + } //CALL + /* the "numbered" messages that follows are used by the directory application, not yet ported */ + if (!strcasecmp(message, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[11]); */ + memset(tech_pvt->skype_friends, 0, 4096); + strncpy(tech_pvt->skype_friends, &message_2[11], 4095); + } + if (!strcasecmp(message, "#222")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_fullname, 0, 512); + strncpy(tech_pvt->skype_fullname, &message_2[10], 511); + } + if (!strcasecmp(message, "#765")) { + /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, + * message_2, &message_2[10]); */ + memset(tech_pvt->skype_displayname, 0, 512); + strncpy(tech_pvt->skype_displayname, &message_2[10], 511); + } + a = 0; + } //message end + } //read_from_pipe + return 0; +} - strncpy(prop, where, sizeof(prop) - 1); +void *skypiax_do_tcp_srv_thread_func(void *obj) +{ + private_t *tech_pvt = obj; + int s; + unsigned int len; + unsigned int i; + unsigned int a; +#if defined(WIN32) && !defined(__CYGWIN__) + int sin_size; +#else /* WIN32 */ + unsigned int sin_size; +#endif /* WIN32 */ + unsigned int fd; + short srv_in[SAMPLES_PER_FRAME]; + short srv_out[SAMPLES_PER_FRAME / 2]; + struct sockaddr_in my_addr; + struct sockaddr_in remote_addr; + int exit = 0; + unsigned int kill_cli_size; + short kill_cli_buff[SAMPLES_PER_FRAME]; + short totalbuf[SAMPLES_PER_FRAME]; - if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop); + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(tech_pvt->tcp_srv_port); - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - } - } + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + ERRORA("socket Error\n", SKYPIAX_P_LOG); + return NULL; + } - if (!strcasecmp(message, "MESSAGE")) { - strncpy(obj, where, sizeof(obj) - 1); + if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { + ERRORA("bind Error\n", SKYPIAX_P_LOG); + return NULL; + } + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - where = strsep(stringp, " "); + listen(s, 6); - strncpy(id, where, sizeof(id) - 1); + sin_size = sizeof(remote_addr); + while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { + DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + if (!running) + break; + while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN + && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { - where = strsep(stringp, " "); + unsigned int fdselect; + int rt; + fd_set fs; + struct timeval to; - strncpy(prop, where, sizeof(prop) - 1); + if (!running) + break; + exit = 1; - if (!strcasecmp(prop, "STATUS")) { + fdselect = fd; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 2000000; //2000 msec + to.tv_sec = 0; - where = strsep(stringp, " "); + rt = select(fdselect + 1, &fs, NULL, NULL, &to); + if (rt > 0) { - strncpy(value, where, sizeof(value) - 1); + len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time - if (!strcasecmp(value, "RECEIVED")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop, value); + if (len == 320) { + unsigned int howmany; - //FIXME: TODO: allow authorization based on config param - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); + if (SAMPLERATE_SKYPIAX == 8000) { + /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */ + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + srv_out[a] = srv_in[i]; + i++; + a++; + } + } else if (SAMPLERATE_SKYPIAX == 16000) { + /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */ + for (i = 0; i < len / sizeof(short); i++) { + srv_out[i] = srv_in[i]; + } + } else { + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + } + /* if not yet done, let's store the half incoming frame */ + if (!tech_pvt->audiobuf_is_loaded) { + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { + tech_pvt->audiobuf[i] = srv_out[i]; + } + tech_pvt->audiobuf_is_loaded = 1; + } else { + /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */ + for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) { + totalbuf[i] = tech_pvt->audiobuf[i]; + } + for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) { + totalbuf[i] = srv_out[a]; + i++; + } + /* send the complete frame through the pipe to our code waiting for incoming audio */ + howmany = + skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf, + SAMPLES_PER_FRAME * sizeof(short)); + if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { + ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, + SAMPLES_PER_FRAME * sizeof(short)); + } + /* done with the stored half frame */ + tech_pvt->audiobuf_is_loaded = 0; } - } else if (!strcasecmp(prop, "BODY")) { - char msg_to_skype[256]; - - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop); - //FIXME: TODO: on config param ??? - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypiax_skype_write(tech_pvt, msg_to_skype); + } else if (len == 0) { + DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); + skypiax_sleep(1000); + } else { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + exit = 1; + break; } + } else { + if (rt) + ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); + skypiax_sleep(10000); } - if (!strcasecmp(message, "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, " "); - - DEBUGA_SKYPE - ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", - SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); - - if (!strcasecmp(prop, "PARTNER_HANDLE")) { - strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_number); - return CALLFLOW_INCOMING_RING; - } - if (!strcasecmp(prop, "PARTNER_DISPNAME")) { - snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", - value, where ? " " : "", where ? where : ""); - DEBUGA_SKYPE - ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n", - SKYPIAX_P_LOG, id, tech_pvt->callid_name); - } - 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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->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 (tech_pvt->interface_state == SKYPIAX_STATE_DOWN) - tech_pvt->interface_state = SKYPIAX_STATE_PRERING; - } + } - if (!strcasecmp(prop, "DTMF")) { + /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */ + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size); + kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); + len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size); - DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); + DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); + skypiax_close_socket(fd); + if (exit) + break; + } - dtmf_received(tech_pvt, value); - } + DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG); + skypiax_close_socket(s); + return NULL; +} - if (!strcasecmp(prop, "FAILUREREASON")) { - 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, tech_pvt->skype_call_id)) { - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE - ("We called a Skype contact and he answered us on skype_call: %s.\n", - SKYPIAX_P_LOG, id); - } - } +void *skypiax_do_tcp_cli_thread_func(void *obj) +{ + private_t *tech_pvt = obj; + int s; + struct sockaddr_in my_addr; + struct sockaddr_in remote_addr; + unsigned int got; + unsigned int len; + unsigned int i; + unsigned int a; + unsigned int fd; + short cli_out[SAMPLES_PER_FRAME * 2]; + short cli_in[SAMPLES_PER_FRAME]; +#ifdef WIN32 + int sin_size; +#else + unsigned int sin_size; +#endif /* WIN32 */ - if (!strcasecmp(prop, "STATUS")) { + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(tech_pvt->tcp_cli_port); - if (!strcasecmp(value, "RINGING")) { - char msg_to_skype[1024]; - if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { - /* we are not calling out */ + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + ERRORA("socket Error\n", SKYPIAX_P_LOG); + return NULL; + } - if (!strlen(tech_pvt->skype_call_id)) { //FIXME - /* we are not inside an active call */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RING; - /* no owner, no active call, let's answer */ - skypiax_skype_write(tech_pvt, "SET AGC OFF"); - skypiax_sleep(10000); - skypiax_skype_write(tech_pvt, "SET AEC OFF"); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(10000); - sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, - id); - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - } else { - /* we're owned, we're in a call, let's refuse */ - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypiax_skype_write(tech_pvt, msg_to_skype); - skypiax_sleep(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); + if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { + ERRORA("bind Error\n", SKYPIAX_P_LOG); + skypiax_close_socket(s); + return NULL; + } + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } - } else { - /* we are calling out */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPIAX_STATE_RINGING; - //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING); - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->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")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - //FIXME ast_queue_control(tech_pvt->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")) { - DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); + listen(s, 6); - } else if (!strcasecmp(value, "FINISHED")) { - //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; + sin_size = sizeof(remote_addr); + while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { + DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + if (!running) + break; + while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN + && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) { + unsigned int fdselect; + int rt; + fd_set fs; + struct timeval to; - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } + if (!running) + break; + fdselect = fd; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 2000000; //2000 msec + to.tv_sec = 0; - } else if (!strcasecmp(value, "CANCELLED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", - SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; + rt = select(fdselect + 1, NULL, &fs, NULL, &to); - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } else if (!strcasecmp(value, "FAILED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", - SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "REFUSED")) { - if (!strcasecmp(id, tech_pvt->skype_call_id)) { - /* this is the id of the call we are in, probably we generated it */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", - SKYPIAX_P_LOG, id); - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - 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); + if (rt > 0) { - } - } else if (!strcasecmp(value, "ROUTING")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "UNPLACED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; - tech_pvt->interface_state = SKYPIAX_STATE_DIALING; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_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_skype_write(tech_pvt, msg_to_skype); + /* read from the pipe the audio frame we are supposed to send out */ + got = + skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, + SAMPLES_PER_FRAME * sizeof(short)); + if (got != SAMPLES_PER_FRAME * sizeof(short)) { + WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + SAMPLES_PER_FRAME * sizeof(short)); + } - tech_pvt->skype_callflow = SKYPIAX_STATE_UP; + if (got == SAMPLES_PER_FRAME * sizeof(short)) { + if (SAMPLERATE_SKYPIAX == 8000) { - if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG); - new_inbound_channel(tech_pvt); - } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); + /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */ + a = 0; + for (i = 0; i < got / sizeof(short); i++) { + cli_out[a] = cli_in[i]; + a++; + cli_out[a] = cli_in[i]; + a++; + } + got = got * 2; + } else if (SAMPLERATE_SKYPIAX == 16000) { + /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */ + for (i = 0; i < got / sizeof(short); i++) { + cli_out[i] = cli_in[i]; } - } else { - WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, - value); + ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); + } + /* send the 16khz frame to the Skype client waiting for incoming audio */ + len = send(fd, (char *) cli_out, got, 0); + + if (len == -1) { + break; + } else if (len != got) { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + skypiax_sleep(1000); + break; } - } //STATUS - } //CALL + } else { - /* the "numbered" messages that follows are used by the directory application, not yet ported */ - if (!strcasecmp(message, "#333")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[11]); */ - memset(tech_pvt->skype_friends, 0, 4096); - strncpy(tech_pvt->skype_friends, &message_2[11], 4095); - } - if (!strcasecmp(message, "#222")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_fullname, 0, 512); - strncpy(tech_pvt->skype_fullname, &message_2[10], 511); - } - if (!strcasecmp(message, "#765")) { - /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG, - * message_2, &message_2[10]); */ - memset(tech_pvt->skype_displayname, 0, 512); - strncpy(tech_pvt->skype_displayname, &message_2[10], 511); + WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, + SAMPLES_PER_FRAME * sizeof(short)); + } + } else { + if (rt) + ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); + skypiax_sleep(10000); } - a = 0; - } //message end - } //read_from_pipe + } + DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG); + skypiax_close_socket(fd); + break; + } - return 0; + DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG); + skypiax_close_socket(s); + return NULL; +} + +int skypiax_skypeaudio_read(private_t * tech_pvt) +{ + unsigned int samples; + + samples = + skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, + SAMPLES_PER_FRAME * sizeof(short)); + + if (samples != SAMPLES_PER_FRAME * sizeof(short)) { + if (samples) + WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, + SAMPLES_PER_FRAME * sizeof(short)); + return 0; + } else { + /* A real frame */ + tech_pvt->read_frame.datalen = samples; + } + return 1; } int skypiax_skype_senddigit(private_t * tech_pvt, char digit) @@ -722,9 +663,7 @@ char msg_to_skype[1024]; DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); - sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit); - skypiax_skype_write(tech_pvt, msg_to_skype); return 0; @@ -743,7 +682,6 @@ sprintf(msg_to_skype, "CALL %s", rdest); if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) { - ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); return -1; } From gmaruzz at freeswitch.org Tue Feb 10 01:19:09 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Feb 2009 03:19:09 -0600 Subject: [Freeswitch-branches] [commit] r11727 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Feb 10 03:19:09 2009 New Revision: 11727 Log: skypiax: shut up the compiler on ubuntu 8.04 64 bit Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Tue Feb 10 03:19:09 2009 @@ -467,7 +467,7 @@ SAMPLES_PER_FRAME * sizeof(short)); if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, - SAMPLES_PER_FRAME * sizeof(short)); + (int)(SAMPLES_PER_FRAME * sizeof(short))); } /* done with the stored half frame */ tech_pvt->audiobuf_is_loaded = 0; @@ -581,7 +581,7 @@ SAMPLES_PER_FRAME * sizeof(short)); if (got != SAMPLES_PER_FRAME * sizeof(short)) { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); + (int)(SAMPLES_PER_FRAME * sizeof(short))); } if (got == SAMPLES_PER_FRAME * sizeof(short)) { @@ -619,7 +619,7 @@ } else { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - SAMPLES_PER_FRAME * sizeof(short)); + (int)(SAMPLES_PER_FRAME * sizeof(short))); } } else { if (rt) @@ -649,7 +649,7 @@ if (samples != SAMPLES_PER_FRAME * sizeof(short)) { if (samples) WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, - SAMPLES_PER_FRAME * sizeof(short)); + (int)(SAMPLES_PER_FRAME * sizeof(short))); return 0; } else { /* A real frame */ From gmaruzz at freeswitch.org Tue Feb 10 08:44:18 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Feb 2009 10:44:18 -0600 Subject: [Freeswitch-branches] [commit] r11728 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Feb 10 10:44:18 2009 New Revision: 11728 Log: skypiax: better audio quality by keeping skype socket busy on *nix and cygwin Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Tue Feb 10 10:44:18 2009 @@ -565,16 +565,25 @@ if (!running) break; - fdselect = fd; FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //2000 msec + to.tv_usec = 60000; //60msec to.tv_sec = 0; +#if defined(WIN32) && !defined(__CYGWIN__) +/* on win32 we cannot select from the apr "pipe", so we select on socket writability */ + fdselect = fd; + FD_SET(fdselect, &fs); rt = select(fdselect + 1, NULL, &fs, NULL, &to); +#else +/* on *unix and cygwin we select from the real pipe */ + fdselect = tech_pvt->audioskypepipe[0]; + FD_SET(fdselect, &fs); - if (rt > 0) { + rt = select(fdselect + 1, &fs, NULL, NULL, &to); +#endif + + if (rt > 0) { /* read from the pipe the audio frame we are supposed to send out */ got = skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in, @@ -622,9 +631,11 @@ (int)(SAMPLES_PER_FRAME * sizeof(short))); } } else { - if (rt) + //if (rt) ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); - skypiax_sleep(10000); + memset(cli_out, 0, sizeof(cli_out)); + len = send(fd, (char *) cli_out, sizeof(cli_out), 0); + //skypiax_sleep(10000); } } From gmaruzz at freeswitch.org Tue Feb 10 13:30:06 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Feb 2009 15:30:06 -0600 Subject: [Freeswitch-branches] [commit] r11733 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Feb 10 15:30:05 2009 New Revision: 11733 Log: skypiax: better sounding by keeping busy with zeros the skype accepting socket when we would not send packets. No more scratches going from one word to another in IVRs Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Tue Feb 10 15:30:05 2009 @@ -474,7 +474,6 @@ } } else if (len == 0) { - DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG); skypiax_sleep(1000); } else { ERRORA("len=%d\n", SKYPIAX_P_LOG, len); @@ -507,7 +506,7 @@ break; } - DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("incoming audio server (I am it) EXITING\n", SKYPIAX_P_LOG); skypiax_close_socket(s); return NULL; } @@ -614,8 +613,9 @@ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } - /* send the 16khz frame to the Skype client waiting for incoming audio */ + /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party*/ len = send(fd, (char *) cli_out, got, 0); + skypiax_sleep(5000); //5 msec if (len == -1) { break; @@ -631,11 +631,12 @@ (int)(SAMPLES_PER_FRAME * sizeof(short))); } } else { - //if (rt) + if (rt) ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); memset(cli_out, 0, sizeof(cli_out)); len = send(fd, (char *) cli_out, sizeof(cli_out), 0); - //skypiax_sleep(10000); + len = send(fd, (char *) cli_out, sizeof(cli_out)/2, 0); + DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2); } } @@ -644,7 +645,7 @@ break; } - DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("outbound audio server (I am it) EXITING\n", SKYPIAX_P_LOG); skypiax_close_socket(s); return NULL; } From gmaruzz at freeswitch.org Tue Feb 10 15:46:42 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 10 Feb 2009 17:46:42 -0600 Subject: [Freeswitch-branches] [commit] r11737 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Tue Feb 10 17:46:42 2009 New Revision: 11737 Log: skypiax: * wait for all interfaces to be connected to Skype client AND identified the correct client on cygwin Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Tue Feb 10 17:46:42 2009 @@ -783,6 +783,7 @@ struct ast_config *cfg; struct skypiax_pvt *tmp; struct skypiax_pvt *p = NULL; + struct skypiax_pvt *p2 = NULL; #ifdef ASTERISK_VERSION_1_6 struct ast_flags config_flags = { 0 }; #endif /* ASTERISK_VERSION_1_6 */ @@ -857,6 +858,28 @@ ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG); return -1; } + /* go through the interfaces list (skypiax_iflist) WITHOUT locking */ + p = skypiax_iflist; + while (p) { + int i; + /* for each interface in list */ + p2 = p->next; + NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name); + i=0; + while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME + usleep(1000); + i++; + } + if (p->SkypiaxHandles.api_connected){ + NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name); + } else { + ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); + running = 0; + return -1; + } + /* next one, please */ + p = p2; + } return 0; } @@ -1832,7 +1855,6 @@ #endif - NOTICA("Here\n", SKYPIAX_P_LOG); return 0; } int outbound_channel_answered(private_t *p) { Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Tue Feb 10 17:46:42 2009 @@ -82,7 +82,7 @@ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message); } if (!strcasecmp(message, "ERROR")) { - WARNINGA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); + DEBUGA_SKYPE("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; @@ -1062,7 +1062,7 @@ (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) { tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle; - while (1) { + while (running) { MSG oMessage; if (!running) break; From gmaruzz at freeswitch.org Wed Feb 11 04:32:35 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Feb 2009 06:32:35 -0600 Subject: [Freeswitch-branches] [commit] r11751 - in freeswitch/branches/gmaruzz/mod_skypiax: . configs Message-ID: Author: gmaruzz Date: Wed Feb 11 06:32:35 2009 New Revision: 11751 Log: skypiax: outbound interface automatic selection, Seven Du patch: you can call skypiax/ANY/another_skypename, it will automatically chose first available channel. Modified: freeswitch/branches/gmaruzz/mod_skypiax/configs/default.xml freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/configs/default.xml ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/configs/default.xml (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/configs/default.xml Wed Feb 11 06:32:35 2009 @@ -266,14 +266,21 @@ - + - + + + + + + + + - + Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Wed Feb 11 06:32:35 2009 @@ -491,8 +491,30 @@ slash = strrchr(interface_name, '/'); *slash = '\0'; - for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) { + if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) { + DEBUGA_SKYPE("Finding one available skype interface\n", + SKYPIAX_P_LOG); + //find an available one, allowing call like originate skypiax/ANY/another_skypename + + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { + int skype_state = 0; + + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; + skype_state = tech_pvt->interface_state; + DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", + SKYPIAX_P_LOG, + i, globals.SKYPIAX_INTERFACES[i].name, skype_state); + if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { + found=1; + break; + } + } + } + } + + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { if (strlen(globals.SKYPIAX_INTERFACES[i].name) && (strncmp From gmaruzz at freeswitch.org Wed Feb 11 12:24:59 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Feb 2009 14:24:59 -0600 Subject: [Freeswitch-branches] [commit] r11890 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Wed Feb 11 14:24:59 2009 New Revision: 11890 Log: skypiax: multiple incoming calls to the same skype_name is working on FS, is working but deadlocks on * ;-) (gotta fix it soon) Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Wed Feb 11 14:24:59 2009 @@ -2316,6 +2316,41 @@ return RESULT_SUCCESS; } + +private_t *find_available_skypiax_interface(void) { + private_t *p; + int found = 0; + + /* lock the interfaces' list */ + LOKKA(&skypiax_iflock); + /* make a pointer to the first interface in the interfaces list */ + p = skypiax_iflist; + /* Search for the requested interface and verify if is unowned */ + while (p) { + if (!p->owner) { + DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG); + found = 1; + /* we found the requested interface, bail out from the while loop */ + break; + } else { + /* interface owned by a channel */ + DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG); + } + /* not yet found, next please */ + p = p->next; + } + + /* lock the interfaces' list */ + UNLOCKA(&skypiax_iflock); + + + if(found) + return p; + else + return NULL; +} + + /************************************************/ #ifdef ASTERISK_VERSION_1_4 #ifndef AST_MODULE Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Wed Feb 11 14:24:59 2009 @@ -415,6 +415,7 @@ int skypiax_pipe_write(int pipe, short *buf, int howmany); #endif /* WIN32 */ int skypiax_close_socket(unsigned int fd); +private_t *find_available_skypiax_interface(void); #define SKYPIAX_STATE_DOWN AST_STATE_DOWN #define SKYPIAX_STATE_RING AST_STATE_RING #define SKYPIAX_STATE_DIALING AST_STATE_DIALING Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Wed Feb 11 14:24:59 2009 @@ -1187,6 +1187,32 @@ return 0; } +private_t *find_available_skypiax_interface(void) { + private_t *tech_pvt; + int found = 0; + int i; + + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { + int skype_state = 0; + + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; + skype_state = tech_pvt->interface_state; + NOTICA("skype interface: %d, name: %s, state: %d\n", + SKYPIAX_P_LOG, + i, globals.SKYPIAX_INTERFACES[i].name, skype_state); + if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { + found=1; + break; + } + } + } + + if(found) + return tech_pvt; + else + return NULL; +} /* For Emacs: * Local Variables: * mode:c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Wed Feb 11 14:24:59 2009 @@ -269,3 +269,4 @@ int skypiax_pipe_write(int pipe, short *buf, int howmany); #endif /* WIN32 */ int skypiax_close_socket(unsigned int fd); +private_t *find_available_skypiax_interface(void); Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Wed Feb 11 14:24:59 2009 @@ -56,7 +56,7 @@ ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", SKYPIAX_P_LOG); skypiax_sleep(1000000); - skypiax_skype_write(tech_pvt, "PROTOCOL 6"); + skypiax_skype_write(tech_pvt, "PROTOCOL 7"); skypiax_sleep(10000); return 0; } @@ -224,17 +224,34 @@ skypiax_sleep(10000); sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); skypiax_skype_write(tech_pvt, msg_to_skype); - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, + NOTICA("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, id); strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); } else { - /* we're owned, we're in a call, let's refuse */ + /* we're owned, we're in a call, let's try to transfer */ + /************************** TODO + Checking here if it is possible to transfer this call to Test2 + -> GET CALL 288 CAN_TRANSFER Test2 + <- CALL 288 CAN_TRANSFER test2 TRUE + **********************************/ + + private_t *available_skypiax_interface; + + available_skypiax_interface = find_available_skypiax_interface(); + if(available_skypiax_interface){ + /* there is a skypiax interface idle, let's transfer the call to it */ + NOTICA ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id); + sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypiax_interface->name); + } else{ + /* no skypiax interfaces idle, let's refuse the call */ + NOTICA ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); + } skypiax_skype_write(tech_pvt, msg_to_skype); skypiax_sleep(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); + NOTICA + ("We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n", + SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); } } else { /* we are calling out */ @@ -251,16 +268,22 @@ 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")) { - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - } else if (!strcasecmp(value, "CANCELLED")) { + } else if (!strcasecmp(value, "FINISHED")) { + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + if(!strcasecmp(tech_pvt->skype_call_id, id)){ + NOTICA("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + }else { + NOTICA("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id); + } + + } else if (!strcasecmp(value, "CANCELLED")) { tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; DEBUGA_SKYPE ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", @@ -306,28 +329,33 @@ tech_pvt->interface_state = SKYPIAX_STATE_DIALING; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_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_skype_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); - new_inbound_channel(tech_pvt); - } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); - } - } else { + } else if (!strcasecmp(value, "INPROGRESS")) { + char msg_to_skype[1024]; + + if(!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) || !strcasecmp(tech_pvt->skype_call_id, id)){ + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_UP; + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_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); + new_inbound_channel(tech_pvt); + } else { + DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); + outbound_channel_answered(tech_pvt); + } + }else { + NOTICA("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); + } + } else { WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, value); } @@ -636,7 +664,7 @@ memset(cli_out, 0, sizeof(cli_out)); len = send(fd, (char *) cli_out, sizeof(cli_out), 0); len = send(fd, (char *) cli_out, sizeof(cli_out)/2, 0); - DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2); + //DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2); } } @@ -1286,7 +1314,7 @@ return NULL; } - snprintf(buf, 512, "PROTOCOL 6"); + snprintf(buf, 512, "PROTOCOL 7"); if (!skypiax_skype_send_message(SkypiaxHandles, buf)) { ERRORA ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", From gmaruzz at freeswitch.org Wed Feb 11 12:47:34 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 11 Feb 2009 14:47:34 -0600 Subject: [Freeswitch-branches] [commit] r11891 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Wed Feb 11 14:47:34 2009 New Revision: 11891 Log: skypiax: corrected type in config file, a tcp port was used twice Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.conf Wed Feb 11 14:47:34 2009 @@ -1,121 +1,207 @@ -;; -;; -; Skypiax Asterisk Driver -; -; Configuration file -; lines beginning with semicolon (" are ignored (commented out) -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; The first interface (named skypeclient) -[skypeclient] -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; general settings, valid on all platforms -; -; -; Default language -; +;;;;;;;; +;;;;;;;; +;;;;;;; Skypiax Asterisk Driver +;;;;;;; +;;;;;;; Configuration file +;;;;;;; lines beginning with semicolon (" are ignored (commented out) +;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;; +;;;;;;; The first interface (named skypeclient) +;;;;;;[skypeclient] +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;; general settings, valid on all platforms +;;;;;;; +;;;;;;; +;;;;;;; Default language +;;;;;;; +;;;;;;language=en +;;;;;;; +;;;;;;; Default context (in extensions.conf, can be overridden with @context syntax) +;;;;;;; +;;;;;;context=default +;;;;;;; +;;;;;;; Default extension (in extensions.conf) where incoming calls land +;;;;;;; +;;;;;;extension=s +;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;; Debugging settings, valid globally for all interfaces on all platforms +;;;;;;; +;;;;;;; the debug values are global for all the interfaces. +;;;;;;; +;;;;;;; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax +;;;;;;; +;;;;;;; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch +;;;;;;; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages +;;;;;;; +;;;;;;; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all +;;;;;;; debug_all activate all possible debugging info +;;;;;;; +;;;;;;;debug_all=yes +;;;;;;debug_skype=yes +;;;;;;debug_pbx=yes +;;;;;;;debug_sound=yes +;;;;;;;debug_locks=yes +;;;;;;;debug_monitorlocks=yes +;;;;;; +;;;;;;skype=yes ; legacy setting, leave it to yes +;;;;;;X11_display=:101 +;;;;;;tcp_cli_port=11234 +;;;;;;tcp_srv_port=11235 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels +;;;;;;; tweak it if you get horrible (or not hearable) sound +;;;;;;; +;;;;;;;boost can be positive or negative (-40 to +40) in db +;;;;;;;experiment to find which values are best for your computer +;;;;;;playback_boost=0 ; +;;;;;;capture_boost=0 ; +;;;;;; +;;; [skypiax1] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:101 +;;; tcp_cli_port=15576 +;;; tcp_srv_port=15577 +;;; skype_user=skypiax1 +;;; +;;; [skypiax2] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:102 +;;; tcp_cli_port=15578 +;;; tcp_srv_port=15579 +;;; skype_user=skypiax2 +;;; +;;; [skypiax3] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:103 +;;; tcp_cli_port=15580 +;;; tcp_srv_port=15581 +;;; skype_user=skypiax3 +;;; +[skypiax4] language=en -; -; Default context (in extensions.conf, can be overridden with @context syntax) -; context=default -; -; Default extension (in extensions.conf) where incoming calls land -; extension=s -; -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; Debugging settings, valid globally for all interfaces on all platforms -; -; the debug values are global for all the interfaces. -; -; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax -; -; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch -; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages -; -; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all -; debug_all activate all possible debugging info -; -;debug_all=yes debug_skype=yes debug_pbx=yes -;debug_sound=yes -;debug_locks=yes -;debug_monitorlocks=yes +skype=yes ; legacy setting, leave it to yes +playback_boost=0 ; +capture_boost=0 ; +X11_display=:104 +tcp_cli_port=15582 +tcp_srv_port=15583 +skype_user=skypiax4 +[skypiax5] +language=en +context=default +extension=s +debug_skype=yes +debug_pbx=yes +skype=yes ; legacy setting, leave it to yes +playback_boost=0 ; +capture_boost=0 ; +X11_display=:105 +tcp_cli_port=15584 +tcp_srv_port=15585 +skype_user=skypiax5 + +[skypiax6] +language=en +context=default +extension=s +debug_skype=yes +debug_pbx=yes skype=yes ; legacy setting, leave it to yes -X11_display=:101 -tcp_cli_port=11234 -tcp_srv_port=11235 -skype_user=gmaruzz2 -;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;; -; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels -; tweak it if you get horrible (or not hearable) sound -; -;boost can be positive or negative (-40 to +40) in db -;experiment to find which values are best for your computer playback_boost=0 ; capture_boost=0 ; +X11_display=:106 +tcp_cli_port=15586 +tcp_srv_port=16586 +skype_user=skypiax6 -;;;[skypeclient2] -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; general settings, valid on all platforms -;;;; -;;;; -;;;; Default language -;;;; -;;;language=en -;;;; -;;;; Default context (in extensions.conf, can be overridden with @context syntax) -;;;; -;;;context=default -;;;; -;;;; Default extension (in extensions.conf) where incoming calls land -;;;; -;;;extension=s -;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; Debugging settings, valid globally for all interfaces on all platforms -;;;; -;;;; the debug values are global for all the interfaces. -;;;; -;;;; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax -;;;; -;;;; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch -;;;; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages -;;;; -;;;; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all -;;;; debug_all activate all possible debugging info -;;;; -;;;;debug_all=yes -;;;debug_skype=yes -;;;debug_pbx=yes -;;;;debug_sound=yes -;;;;debug_locks=yes -;;;;debug_monitorlocks=yes -;;; -;;;skype=yes ; legacy setting, leave it to yes -;;;X11_display=:102 -;;;tcp_cli_port=11236 -;;;tcp_srv_port=11237 -;;;skype_user=gmaruzz3 -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels -;;;; tweak it if you get horrible (or not hearable) sound -;;;; -;;;;boost can be positive or negative (-40 to +40) in db -;;;;experiment to find which values are best for your computer -;;;playback_boost=0 ; -;;;capture_boost=0 ; -;;; -;;; +;;; [skypiax17] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:117 +;;; tcp_cli_port=15587 +;;; tcp_srv_port=15588 +;;; skype_user=skypiax17 +;;; +;;; [skypiax18] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:118 +;;; tcp_cli_port=15589 +;;; tcp_srv_port=15590 +;;; skype_user=skypiax18 +;;; +;;; [skypiax19] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:119 +;;; tcp_cli_port=15591 +;;; tcp_srv_port=15592 +;;; skype_user=skypiax19 +;;; +;;; [skypiax20] +;;; language=en +;;; context=default +;;; extension=s +;;; debug_skype=yes +;;; debug_pbx=yes +;;; skype=yes ; legacy setting, leave it to yes +;;; playback_boost=0 ; +;;; capture_boost=0 ; +;;; X11_display=:120 +;;; tcp_cli_port=15593 +;;; tcp_srv_port=15594 +;;; skype_user=skypiax20 +;;; +;;; +;;; From gmaruzz at freeswitch.org Thu Feb 12 01:01:03 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 03:01:03 -0600 Subject: [Freeswitch-branches] [commit] r11916 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Feb 12 03:01:03 2009 New Revision: 11916 Log: skypiax: cleaning... Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Thu Feb 12 03:01:03 2009 @@ -492,29 +492,15 @@ *slash = '\0'; if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) { + /* we've been asked for the "ANY" interface, let's find the first idle interface */ DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG); - //find an available one, allowing call like originate skypiax/ANY/another_skypename - - for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { - int skype_state = 0; - - tech_pvt = &globals.SKYPIAX_INTERFACES[i]; - skype_state = tech_pvt->interface_state; - DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", - SKYPIAX_P_LOG, - i, globals.SKYPIAX_INTERFACES[i].name, skype_state); - if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { - found=1; - break; - } - } - } + tech_pvt = find_available_skypiax_interface(); + if(tech_pvt) + found=1; } - - for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ if (strlen(globals.SKYPIAX_INTERFACES[i].name) && (strncmp @@ -528,7 +514,7 @@ DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name); - tech_pvt = &globals.SKYPIAX_INTERFACES[i]; //FIXME + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; found = 1; break; } @@ -895,7 +881,7 @@ DEBUGA_SKYPE ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context); - NOTICA("Trying to START interface_id=%d\n", SKYPIAX_P_LOG, interface_id); + NOTICA("STARTING interface_id=%d\n", SKYPIAX_P_LOG, interface_id); switch_threadattr_create(&skypiax_skypeapi_thread_attr, skypiax_module_pool); switch_threadattr_stacksize_set(skypiax_skypeapi_thread_attr, @@ -917,7 +903,7 @@ &globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); - switch_sleep(1000000); + switch_sleep(100000); skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]); @@ -1080,7 +1066,7 @@ if (channel) { switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; - NOTICA("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, + DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, switch_channel_get_name(channel)); switch_mutex_lock(tech_pvt->flag_mutex); //FIXME: why sometimes DTMFs from here do not seems to be get by FS? @@ -1198,7 +1184,7 @@ tech_pvt = &globals.SKYPIAX_INTERFACES[i]; skype_state = tech_pvt->interface_state; - NOTICA("skype interface: %d, name: %s, state: %d\n", + DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, skype_state); if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Thu Feb 12 03:01:03 2009 @@ -185,7 +185,7 @@ tech_pvt->interface_state = SKYPIAX_STATE_PRERING; } if (!strcasecmp(prop, "DTMF")) { - NOTICA("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); + DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); dtmf_received(tech_pvt, value); } if (!strcasecmp(prop, "FAILUREREASON")) { @@ -224,7 +224,7 @@ skypiax_sleep(10000); sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); skypiax_skype_write(tech_pvt, msg_to_skype); - NOTICA("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, id); strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); } else { @@ -240,16 +240,16 @@ available_skypiax_interface = find_available_skypiax_interface(); if(available_skypiax_interface){ /* there is a skypiax interface idle, let's transfer the call to it */ - NOTICA ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id); + DEBUGA_SKYPE ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id); sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypiax_interface->name); } else{ /* no skypiax interfaces idle, let's refuse the call */ - NOTICA ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); + DEBUGA_SKYPE ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); } skypiax_skype_write(tech_pvt, msg_to_skype); skypiax_sleep(10000); - NOTICA + DEBUGA_SKYPE ("We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); } @@ -271,7 +271,7 @@ } else if (!strcasecmp(value, "FINISHED")) { DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); if(!strcasecmp(tech_pvt->skype_call_id, id)){ - NOTICA("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id); + DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id); tech_pvt->skype_call_id[0] = '\0'; if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; @@ -280,7 +280,7 @@ tech_pvt->interface_state = SKYPIAX_STATE_DOWN; } }else { - NOTICA("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id); + DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id); } } else if (!strcasecmp(value, "CANCELLED")) { @@ -353,7 +353,7 @@ outbound_channel_answered(tech_pvt); } }else { - NOTICA("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); + DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); } } else { WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, @@ -905,7 +905,7 @@ DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG); break; case WM_DESTROY: - NOTICA("got DESTROY\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("got DESTROY\n", SKYPIAX_P_LOG); tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL; PostQuitMessage(0); break; @@ -924,7 +924,7 @@ howmany = skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype, howmany); - //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); + //DEBUGA_SKYPE("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype); lReturnCode = 1; } break; From gmaruzz at freeswitch.org Thu Feb 12 01:04:35 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 03:04:35 -0600 Subject: [Freeswitch-branches] [commit] r11917 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk Message-ID: Author: gmaruzz Date: Thu Feb 12 03:04:35 2009 New Revision: 11917 Log: skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Thu Feb 12 03:04:35 2009 @@ -12,7 +12,7 @@ /* GLOBAL VARIABLES */ int running = 1; -int skypiax_dir_entry_extension=1; //FIXME one var for each interface! +int skypiax_dir_entry_extension = 1; //FIXME one var for each interface! char skypiax_console_active_array[50] = ""; char *skypiax_console_active = skypiax_console_active_array; /*! \brief Count of active channels for this module */ @@ -286,7 +286,6 @@ struct ast_channel *tmp = NULL; char *name = data; - DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format); @@ -442,10 +441,11 @@ usleep(10000); //10msec } if (p->interface_state != SKYPIAX_STATE_UP) { - ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state); + ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", + SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state); res = -1; } else { - DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG); + DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG); res = 0; } return res; @@ -501,7 +501,6 @@ short *buf; int samples; - /* if there are control frames queued to be sent by skypiax_queue_control, send it the first */ //TODO maybe better a real queue? if (p && p->owner && p->control_to_send) { @@ -572,8 +571,8 @@ return -1; } - DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest, - timeout); + DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest, + timeout); strncpy(rdest, idest, sizeof(rdest) - 1); stringp = rdest; @@ -586,8 +585,8 @@ } strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1); - DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, - idest, timeout, dstr); + DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, + idest, timeout, dstr); strcpy(p->session_uuid_str, "dialing"); status = skypiax_skype_call(p, dstr, timeout); @@ -596,8 +595,8 @@ return -1; } - DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, - idest, timeout, dstr); + DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, + idest, timeout, dstr); ast_setstate(p->owner, SKYPIAX_STATE_DIALING); return 0; @@ -861,24 +860,24 @@ /* go through the interfaces list (skypiax_iflist) WITHOUT locking */ p = skypiax_iflist; while (p) { - int i; - /* for each interface in list */ - p2 = p->next; - NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name); - i=0; - while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME - usleep(1000); - i++; - } - if (p->SkypiaxHandles.api_connected){ - NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name); - } else { - ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); - running = 0; - return -1; - } - /* next one, please */ - p = p2; + int i; + /* for each interface in list */ + p2 = p->next; + NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name); + i = 0; + while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME + usleep(1000); + i++; + } + if (p->SkypiaxHandles.api_connected) { + NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name); + } else { + ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); + running = 0; + return -1; + } + /* next one, please */ + p = p2; } return 0; } @@ -898,7 +897,6 @@ struct skypiax_pvt *p = NULL, *p2 = NULL; int res; - /* unregister our channel type with Asterisk */ ast_channel_unregister(&skypiax_tech); ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry)); @@ -1024,7 +1022,7 @@ { struct skypiax_pvt *p = NULL; - NOTICA("Returning Key\n", SKYPIAX_P_LOG); + NOTICA("Returning Key\n", SKYPIAX_P_LOG); return ASTERISK_GPL_KEY; } @@ -1080,7 +1078,8 @@ skypiax_store_boost(v->value, &skypiax_default.capture_boost)) M_UINT("skypiax_dir_entry_extension_prefix", skypiax_default.skypiax_dir_entry_extension_prefix) - M_END(;); + M_END(; + ); } } @@ -1116,7 +1115,8 @@ 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) { @@ -1231,34 +1231,33 @@ return NULL; } /* - res = pipe(tmp->SkypiaxHandles.fdesc); - if (res) { - ast_log(LOG_ERROR, "Unable to create skype pipe\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } - free(tmp); - return NULL; - } - fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); - */ + res = pipe(tmp->SkypiaxHandles.fdesc); + if (res) { + ast_log(LOG_ERROR, "Unable to create skype pipe\n"); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); + } + free(tmp); + return NULL; + } + fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); + fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); + */ tmp->skype_thread = AST_PTHREADT_NULL; if (tmp->skype) { - ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, - (unsigned long) AST_PTHREADT_NULL); + ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n", + (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, + (unsigned long) AST_PTHREADT_NULL); #ifdef __CYGWIN__ - if (ast_pthread_create - (&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { + if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); free(tmp); return NULL; } #else /* __CYGWIN__ */ #ifdef WANT_SKYPE_X11 - ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]); + ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]); if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); free(tmp); @@ -1266,18 +1265,16 @@ } #endif /* WANT_SKYPE_X11 */ #endif /* __CYGWIN__ */ - usleep(100000); //0.1 sec - if( tmp->skype_thread == AST_PTHREADT_NULL){ + usleep(100000); //0.1 sec + if (tmp->skype_thread == AST_PTHREADT_NULL) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); free(tmp); return NULL; } - ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, - (unsigned long) AST_PTHREADT_NULL); + ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n", + (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, + (unsigned long) AST_PTHREADT_NULL); } - - #if 0 if (tmp->skype) { #if 0 @@ -1298,7 +1295,8 @@ } #else /* __CYGWIN__ */ #ifdef WANT_SKYPE_X11 - if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) < 0) { + if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) < + 0) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); @@ -1308,8 +1306,8 @@ } #endif /* WANT_SKYPE_X11 */ #endif /* __CYGWIN__ */ - usleep(100000); //0.1 sec - if( tmp->skype_thread == AST_PTHREADT_NULL){ + usleep(100000); //0.1 sec + if (tmp->skype_thread == AST_PTHREADT_NULL) { ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); @@ -1322,12 +1320,8 @@ (unsigned long) tmp->signaling_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); } - #endif - - - /* return the newly created skypiax_pvt */ return tmp; } @@ -1522,7 +1516,7 @@ int res; res = skypiax_skypeaudio_read(p); - f = &p->read_frame; + f = &p->read_frame; return f; } @@ -1557,7 +1551,7 @@ if (p->skype) { res = skypiax_skype_read(p); if (res == CALLFLOW_INCOMING_HANGUP) { - DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); if (p->owner) { pthread_testcancel(); ast_queue_control(p->owner, AST_CONTROL_HANGUP); @@ -1596,7 +1590,7 @@ *boost = BOOST_MAX; } *boost = exp(log(10) * *boost / 20) * BOOST_SCALE; - DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost); + DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost); } /* @@ -1758,147 +1752,140 @@ void *do_skypeapi_thread(void *obj) { - return skypiax_do_skypeapi_thread_func(obj); + return skypiax_do_skypeapi_thread_func(obj); } -int dtmf_received(private_t *p, char *value){ +int dtmf_received(private_t * p, char *value) +{ - struct ast_frame f2 = { AST_FRAME_DTMF, value[0], }; - DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value); - ast_queue_frame(p->owner, &f2); + struct ast_frame f2 = { AST_FRAME_DTMF, value[0], }; + DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value); + ast_queue_frame(p->owner, &f2); - return 0; + return 0; } -int start_audio_threads(private_t *p) { - //if (!p->tcp_srv_thread) { - if (ast_pthread_create - (&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) { - ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - return -1; - } else { - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - } - //} - //if (!p->tcp_cli_thread) { - 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); - return -1; - } else { - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } - //} +int start_audio_threads(private_t * p) +{ + //if (!p->tcp_srv_thread) { + if (ast_pthread_create(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) { + ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + return -1; + } else { + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + } + //} + //if (!p->tcp_cli_thread) { + 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); + return -1; + } else { + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + } + //} #ifdef NOTDEF - switch_threadattr_t *thd_attr = NULL; + switch_threadattr_t *thd_attr = NULL; + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, + tech_pvt, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, + tech_pvt, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + switch_sleep(100000); - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, - skypiax_do_tcp_srv_thread, tech_pvt, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, - skypiax_do_tcp_cli_thread, tech_pvt, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - switch_sleep(100000); - #endif - return 0; + return 0; } -int new_inbound_channel(private_t *p) { +int new_inbound_channel(private_t * p) +{ #ifdef NOTDEF - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if ((session = - switch_core_session_request(skypiax_endpoint_interface, - NULL)) != 0) { - switch_core_session_add_stream(session, NULL); - channel = switch_core_session_get_channel(session); - skypiax_tech_init(tech_pvt, session); - - if ((tech_pvt->caller_profile = - switch_caller_profile_new(switch_core_session_get_pool(session), - "skypiax", tech_pvt->dialplan, - tech_pvt->callid_name, - tech_pvt->callid_number, NULL, NULL, - NULL, NULL, "mod_skypiax", - tech_pvt->context, - tech_pvt->destination)) != 0) { - char name[128]; - //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number); - switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name); - switch_channel_set_name(channel, name); - switch_channel_set_caller_profile(channel, - tech_pvt->caller_profile); - } - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != - SWITCH_STATUS_SUCCESS) { - ERRORA("Error spawning thread\n", SKYPIAX_P_LOG); - switch_core_session_destroy(&session); - } - } - switch_channel_mark_answered(channel); + switch_core_session_t *session = NULL; + switch_channel_t *channel = NULL; + if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) { + switch_core_session_add_stream(session, NULL); + channel = switch_core_session_get_channel(session); + skypiax_tech_init(tech_pvt, session); + + if ((tech_pvt->caller_profile = + switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax", + tech_pvt->dialplan, tech_pvt->callid_name, + tech_pvt->callid_number, NULL, NULL, NULL, NULL, + "mod_skypiax", tech_pvt->context, + tech_pvt->destination)) != 0) { + char name[128]; + //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number); + switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name); + switch_channel_set_name(channel, name); + switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); + } + switch_channel_set_state(channel, CS_INIT); + if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { + ERRORA("Error spawning thread\n", SKYPIAX_P_LOG); + switch_core_session_destroy(&session); + } + } + switch_channel_mark_answered(channel); #endif - return 0; + return 0; } -int outbound_channel_answered(private_t *p) { -#ifdef NOTDEF - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; +int outbound_channel_answered(private_t * p) +{ +#ifdef NOTDEF + switch_core_session_t *session = NULL; + switch_channel_t *channel = NULL; - if (strlen(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session???\n", SKYPIAX_P_LOG); - } - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No session???\n", SKYPIAX_P_LOG); - } - if (channel) { - switch_channel_mark_answered(channel); - //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); - } else { - ERRORA("No channel???\n", SKYPIAX_P_LOG); - } + if (strlen(tech_pvt->session_uuid_str)) { + session = switch_core_session_locate(tech_pvt->session_uuid_str); + } else { + ERRORA("No session???\n", SKYPIAX_P_LOG); + } + if (session) { + channel = switch_core_session_get_channel(session); + } else { + ERRORA("No session???\n", SKYPIAX_P_LOG); + } + if (channel) { + switch_channel_mark_answered(channel); + //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); + } else { + ERRORA("No channel???\n", SKYPIAX_P_LOG); + } - switch_core_session_rwunlock(session); + switch_core_session_rwunlock(session); #endif - if (p->owner) { - ast_queue_control(p->owner, AST_CONTROL_ANSWER); - } + if (p->owner) { + ast_queue_control(p->owner, AST_CONTROL_ANSWER); + } - NOTICA("HERE!\n", SKYPIAX_P_LOG); + NOTICA("HERE!\n", SKYPIAX_P_LOG); - return 0; + return 0; } -void * skypiax_do_tcp_srv_thread(void *obj) +void *skypiax_do_tcp_srv_thread(void *obj) { - return skypiax_do_tcp_srv_thread_func(obj); + return skypiax_do_tcp_srv_thread_func(obj); } -void * skypiax_do_tcp_cli_thread(void *obj) +void *skypiax_do_tcp_cli_thread(void *obj) { - return skypiax_do_tcp_cli_thread_func(obj); + return skypiax_do_tcp_cli_thread_func(obj); } int skypiax_skypeaudio_write(struct skypiax_pvt *p, struct ast_frame *f) @@ -1962,10 +1949,11 @@ //int fromcell = 0; #if 0 - if(directoriax_entry_extension){ - skypiax_dir_entry_extension=directoriax_entry_extension; - }else{ - ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); + if (directoriax_entry_extension) { + skypiax_dir_entry_extension = directoriax_entry_extension; + } else { + ast_cli(fd, + "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); return RESULT_SUCCESS; } #endif @@ -2027,7 +2015,7 @@ } else { snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); } - NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); + NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); time(&t); ast_copy_string(date, ctime(&t), sizeof(date)); @@ -2038,13 +2026,13 @@ if (p->phonebook_writing_fp) { if (add_to_skypiax_dir_conf) { - NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); + NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); fprintf(p->phonebook_writing_fp, ";!\n"); fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); fprintf(p->phonebook_writing_fp, ";!\n"); } else { - NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); + NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); fprintf(p->phonebook_writing_fp, ";!\n"); fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn); @@ -2057,117 +2045,198 @@ /*******************************************************************************************/ //if (fromskype) { - if (p->skype) { - WARNINGA - ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", - SKYPIAX_P_LOG); - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; + if (p->skype) { + WARNINGA + ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", + SKYPIAX_P_LOG); + if (p->skype_thread != AST_PTHREADT_NULL) { + char msg_to_skype[1024]; + + p->skype_friends[0] = '\0'; + sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); + if (skypiax_skype_write(p, msg_to_skype) < 0) { + return -1; + } - p->skype_friends[0] = '\0'; - sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); - if (skypiax_skype_write(p, msg_to_skype) < 0) { - return -1; + int friends_count = 0; + while (p->skype_friends[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + friends_count++; + if (friends_count > 20000) { + return -1; /* FIXME */ } + } - int friends_count = 0; - while (p->skype_friends[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - friends_count++; - if (friends_count > 20000) { - return -1; /* FIXME */ - } - } + } - } + if (p->skype_thread != AST_PTHREADT_NULL) { + char msg_to_skype[1024]; - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; + if (p->skype_friends[0] != '\0') { + char *buf, *where; + char **stringp; + int skype_dir_file_written = 0; + + buf = p->skype_friends; + stringp = &buf; + where = strsep(stringp, ", "); + while (where) { + if (where[0] != '\0') { + /* + * So, we have the Skype username (the HANDLE, I think is called). + * But we want to call the names we see in the Skype contact list + * So, let's check the DISPLAYNAME (the end user modified contact name) + * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME + * if the end user has not modify it) + * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the + * Skipe username (the HANDLE) + */ + + p->skype_displayname[0] = '\0'; + sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); + skypiax_skype_write(p, msg_to_skype); + int displayname_count = 0; + while (p->skype_displayname[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + displayname_count++; + if (displayname_count > 20000) + return -1; /* FIXME */ + } + if (p->skype_displayname[0] != '\0') { + char *where2; + char sanitized[300]; + + sanitized[0] = '\0'; + + where2 = strstr(p->skype_displayname, "DISPLAYNAME "); + if (where2) { + + /* there can be some *smart* that makes a displayname + * that is different than firstlast, */ + /* maybe initials, simbols, slashes, + * something smartish... let's check */ + + if (where2[12] != '\0') { + int i = 12; + int x = 0; + int spaces = 0; + int last_char_was_space = 0; + + for (i = 12; i < strlen(where2) && x < 299; i++) { + if (!isalnum(where2[i])) { + if (!isblank(where2[i])) { + /* bad char */ + continue; + } + /* is a space */ + if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ + continue; + last_char_was_space = 1; + sanitized[x] = ' '; + x++; + continue; + } + /* is alphanum */ + last_char_was_space = 0; + sanitized[x] = where2[i]; + x++; + continue; + } - if (p->skype_friends[0] != '\0') { - char *buf, *where; - char **stringp; - int skype_dir_file_written = 0; + sanitized[x] = '\0'; + if (spaces == 0) { + } + DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", + SKYPIAX_P_LOG, sanitized, where, &where2[12]); + } - buf = p->skype_friends; - stringp = &buf; - where = strsep(stringp, ", "); - while (where) { - if (where[0] != '\0') { - /* - * So, we have the Skype username (the HANDLE, I think is called). - * But we want to call the names we see in the Skype contact list - * So, let's check the DISPLAYNAME (the end user modified contact name) - * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME - * if the end user has not modify it) - * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the - * Skipe username (the HANDLE) - */ - - p->skype_displayname[0] = '\0'; - sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); - skypiax_skype_write(p, msg_to_skype); - int displayname_count = 0; - while (p->skype_displayname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - displayname_count++; - if (displayname_count > 20000) - return -1; /* FIXME */ + if (where2[12] != '\0') { + skypiax_dir_entry_extension++; + if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "2", + skypiax_dir_entry_extension, "yes", "not_specified"); + } else { /* is a skype name */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, sanitized, "no", + p->skypiax_dir_entry_extension_prefix, "1", + skypiax_dir_entry_extension, "yes", "not_specified"); + } + skype_dir_file_written = 1; + + } } - if (p->skype_displayname[0] != '\0') { - char *where2; - char sanitized[300]; - - sanitized[0] = '\0'; - - where2 = strstr(p->skype_displayname, "DISPLAYNAME "); - if (where2) { - - /* there can be some *smart* that makes a displayname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[12] != '\0') { - int i = 12; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 12; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; + } + p->skype_displayname[0] = '\0'; + + p->skype_fullname[0] = '\0'; + sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); + skypiax_skype_write(p, msg_to_skype); + int fullname_count = 0; + while (p->skype_fullname[0] == '\0') { + /* FIXME needs a timeout, can't wait forever! + * eg. when skype is running but not connected! */ + usleep(100); + fullname_count++; + if (fullname_count > 20000) + return -1; /* FIXME */ + } + if (p->skype_fullname[0] != '\0') { + char *where2; + char sanitized[300]; + + where2 = strstr(p->skype_fullname, "FULLNAME "); + if (where2) { + + /* there can be some *smart* that makes a fullname + * that is different than firstlast, */ + /* maybe initials, simbols, slashes, + * something smartish... let's check */ + + if (where2[9] != '\0') { + int i = 9; + int x = 0; + int spaces = 0; + int last_char_was_space = 0; + + for (i = 9; i < strlen(where2) && x < 299; i++) { + if (!isalnum(where2[i])) { + if (!isblank(where2[i])) { + /* bad char */ continue; } - /* is alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; + /* is a space */ + if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ + continue; + last_char_was_space = 1; + sanitized[x] = ' '; x++; continue; } + /* alphanum */ + last_char_was_space = 0; + sanitized[x] = where2[i]; + x++; + continue; + } - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[12]); + sanitized[x] = '\0'; + if (spaces == 0) { } + DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", + SKYPIAX_P_LOG, sanitized, where, &where2[9]); + } - if (where2[12] != '\0') { - skypiax_dir_entry_extension++; + if (skype_dir_file_written == 0) { + skypiax_dir_entry_extension++; + if (where2[9] != '\0') { if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ fprintf(p->phonebook_writing_fp, "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", @@ -2180,127 +2249,44 @@ where, sanitized, "no", p->skypiax_dir_entry_extension_prefix, "1", skypiax_dir_entry_extension, "yes", "not_specified"); - } - skype_dir_file_written = 1; - - } - } - } - p->skype_displayname[0] = '\0'; - - p->skype_fullname[0] = '\0'; - sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); - skypiax_skype_write(p, msg_to_skype); - int fullname_count = 0; - while (p->skype_fullname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - fullname_count++; - if (fullname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_fullname[0] != '\0') { - char *where2; - char sanitized[300]; - - where2 = strstr(p->skype_fullname, "FULLNAME "); - if (where2) { - - /* there can be some *smart* that makes a fullname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[9] != '\0') { - int i = 9; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 9; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - sanitized[x] = '\0'; - if (spaces == 0) { } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", - SKYPIAX_P_LOG, sanitized, where, &where2[9]); - } - - if (skype_dir_file_written == 0) { - skypiax_dir_entry_extension++; - if (where2[9] != '\0') { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); - } - - } else { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "2", - skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", - p->skypiax_dir_entry_extension_prefix, "1", - skypiax_dir_entry_extension, "yes", "not_specified"); + } else { + if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, where, "no", p->skypiax_dir_entry_extension_prefix, + "2", skypiax_dir_entry_extension, "yes", "not_specified"); + } else { /* is a skype name */ + fprintf(p->phonebook_writing_fp, + "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", + where, where, "no", p->skypiax_dir_entry_extension_prefix, + "1", skypiax_dir_entry_extension, "yes", "not_specified"); - } } } - - skype_dir_file_written = 0; - } + skype_dir_file_written = 0; + } - p->skype_fullname[0] = '\0'; } - where = strsep(stringp, ", "); - } + p->skype_fullname[0] = '\0'; - p->skype_friends[0] = '\0'; + } + where = strsep(stringp, ", "); } - } - } else { - ast_cli(fd, - "Skype not configured on the 'current' console, not importing from Skype client!\n"); + p->skype_friends[0] = '\0'; + } } + } else { + + ast_cli(fd, + "Skype not configured on the 'current' console, not importing from Skype client!\n"); + } //} /*******************************************************************************************/ /*******************************************************************************************/ @@ -2317,9 +2303,10 @@ return RESULT_SUCCESS; } -private_t *find_available_skypiax_interface(void) { - private_t *p; - int found = 0; +private_t *find_available_skypiax_interface(void) +{ + private_t *p; + int found = 0; /* lock the interfaces' list */ LOKKA(&skypiax_iflock); @@ -2327,15 +2314,15 @@ p = skypiax_iflist; /* Search for the requested interface and verify if is unowned */ while (p) { - if (!p->owner) { - DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG); - found = 1; + if (!p->owner) { + DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG); + found = 1; /* we found the requested interface, bail out from the while loop */ - break; - } else { - /* interface owned by a channel */ - DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG); - } + break; + } else { + /* interface owned by a channel */ + DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG); + } /* not yet found, next please */ p = p->next; } @@ -2343,14 +2330,12 @@ /* lock the interfaces' list */ UNLOCKA(&skypiax_iflock); - - if(found) - return p; + if (found) + return p; else - return NULL; + return NULL; } - /************************************************/ #ifdef ASTERISK_VERSION_1_4 #ifndef AST_MODULE Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Thu Feb 12 03:04:35 2009 @@ -235,7 +235,6 @@ #endif //WIN32 - /*! * \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif */ @@ -396,13 +395,13 @@ int skypiax_skype_call(struct skypiax_pvt *p, char *idest, int timeout); int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]); -void * skypiax_do_tcp_srv_thread_func(void *obj); -void * skypiax_do_tcp_cli_thread_func(void *obj); -void * skypiax_do_skypeapi_thread_func(void *obj); -int dtmf_received(private_t *tech_pvt, char *value); -int start_audio_threads(private_t *tech_pvt); -int new_inbound_channel(private_t *tech_pvt); -int outbound_channel_answered(private_t *tech_pvt); +void *skypiax_do_tcp_srv_thread_func(void *obj); +void *skypiax_do_tcp_cli_thread_func(void *obj); +void *skypiax_do_skypeapi_thread_func(void *obj); +int dtmf_received(private_t * tech_pvt, char *value); +int start_audio_threads(private_t * tech_pvt); +int new_inbound_channel(private_t * tech_pvt); +int outbound_channel_answered(private_t * tech_pvt); int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit); int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); #if defined(WIN32) && !defined(__CYGWIN__) Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Thu Feb 12 03:04:35 2009 @@ -474,7 +474,7 @@ private_t *tech_pvt; switch_channel_t *channel; switch_caller_profile_t *caller_profile; - char *rdest; + char *rdest; switch_core_session_add_stream(*new_session, NULL); @@ -491,30 +491,32 @@ slash = strrchr(interface_name, '/'); *slash = '\0'; - if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) { - /* we've been asked for the "ANY" interface, let's find the first idle interface */ - DEBUGA_SKYPE("Finding one available skype interface\n", - SKYPIAX_P_LOG); - tech_pvt = find_available_skypiax_interface(); - if(tech_pvt) - found=1; - } + if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) { + /* we've been asked for the "ANY" interface, let's find the first idle interface */ + DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG); + tech_pvt = find_available_skypiax_interface(); + if (tech_pvt) + found = 1; + } for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { - /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ + /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ if (strlen(globals.SKYPIAX_INTERFACES[i].name) && (strncmp (globals.SKYPIAX_INTERFACES[i].name, interface_name, strlen(interface_name)) == 0)) { - if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)){ - DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE ; - } + if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) { + DEBUGA_SKYPE + ("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", + SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, + globals.SKYPIAX_INTERFACES[i].session_uuid_str); + switch_core_session_destroy(new_session); + return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE; + } DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name); - tech_pvt = &globals.SKYPIAX_INTERFACES[i]; + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; found = 1; break; } @@ -557,18 +559,16 @@ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - - rdest = strchr(caller_profile->destination_number, '/'); - *rdest++ = '\0'; - + rdest = strchr(caller_profile->destination_number, '/'); + *rdest++ = '\0'; skypiax_skype_call(tech_pvt, rdest, 30); - switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(*new_session), - sizeof(tech_pvt->session_uuid_str)); - caller_profile = tech_pvt->caller_profile; - caller_profile->destination_number = rdest; - + switch_copy_string(tech_pvt->session_uuid_str, + switch_core_session_get_uuid(*new_session), + sizeof(tech_pvt->session_uuid_str)); + caller_profile = tech_pvt->caller_profile; + caller_profile->destination_number = rdest; switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); @@ -590,7 +590,6 @@ int res; int forever = 1; - DEBUGA_SKYPE("In skypiax_signaling_thread_func: started, p=%p\n", SKYPIAX_P_LOG, (void *) tech_pvt); @@ -639,7 +638,7 @@ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { ERRORA("open of %s failed\n", SKYPIAX_P_LOG, cf); - running=0; + running = 0; return SWITCH_STATUS_TERM; } @@ -820,7 +819,7 @@ memset(&newconf, '\0', sizeof(newconf)); globals.SKYPIAX_INTERFACES[interface_id] = newconf; - tech_pvt=&globals.SKYPIAX_INTERFACES[interface_id]; + tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id]; switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id); if (name) { @@ -907,17 +906,17 @@ skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]); - i=0; - while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME + i = 0; + while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME switch_sleep(1000); - i++; + i++; + } + if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) { + NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id); + } else { + ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id); + return SWITCH_STATUS_FALSE; } - if(globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected){ - NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id); - } else { - ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id); - return SWITCH_STATUS_FALSE; - } } else { ERRORA("interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", @@ -929,7 +928,7 @@ for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) { if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { - tech_pvt = &globals.SKYPIAX_INTERFACES[i]; + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n", SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].interface_id); @@ -963,7 +962,7 @@ running = 1; if (load_config() != SWITCH_STATUS_SUCCESS) - return SWITCH_STATUS_FALSE; + return SWITCH_STATUS_FALSE; *module_interface = switch_loadable_module_create_module_interface(pool, modname); skypiax_endpoint_interface = @@ -972,11 +971,11 @@ skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - if(running) - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; + if (running) + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; else - return SWITCH_STATUS_FALSE; + return SWITCH_STATUS_FALSE; } SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) @@ -1040,165 +1039,156 @@ return SWITCH_STATUS_SUCCESS; } -void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, - void *obj) +void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj) +{ + return skypiax_do_tcp_srv_thread_func(obj); +} +void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj) { - return skypiax_do_tcp_srv_thread_func(obj); + return skypiax_do_tcp_cli_thread_func(obj); } -void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, - void *obj) +void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj) { - return skypiax_do_tcp_cli_thread_func(obj); -} -void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, - void *obj) -{ - return skypiax_do_skypeapi_thread_func(obj); -} - -int dtmf_received(private_t *tech_pvt, char *value){ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - channel = switch_core_session_get_channel(session); - - if (channel) { - switch_dtmf_t dtmf = - { (char) value[0], switch_core_default_dtmf_duration(0) }; - DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, - switch_channel_get_name(channel)); - switch_mutex_lock(tech_pvt->flag_mutex); - //FIXME: why sometimes DTMFs from here do not seems to be get by FS? - switch_channel_queue_dtmf(channel, &dtmf); - switch_set_flag(tech_pvt, TFLAG_DTMF); - switch_mutex_unlock(tech_pvt->flag_mutex); - } else { - WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]); - } - switch_core_session_rwunlock(session); - - return 0; -} - -int start_audio_threads(private_t *tech_pvt) { - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, - skypiax_do_tcp_srv_thread, tech_pvt, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, - skypiax_do_tcp_cli_thread, tech_pvt, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - switch_sleep(100000); - - - return 0; -} - -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, - NULL)) != 0) { - switch_core_session_add_stream(session, NULL); - channel = switch_core_session_get_channel(session); - skypiax_tech_init(tech_pvt, session); - - if ((tech_pvt->caller_profile = - switch_caller_profile_new(switch_core_session_get_pool(session), - "skypiax", tech_pvt->dialplan, - tech_pvt->callid_name, - tech_pvt->callid_number, NULL, NULL, - NULL, NULL, "mod_skypiax", - tech_pvt->context, - tech_pvt->destination)) != 0) { - char name[128]; - //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number); - switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name); - switch_channel_set_name(channel, name); - switch_channel_set_caller_profile(channel, - tech_pvt->caller_profile); - } - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != - SWITCH_STATUS_SUCCESS) { - ERRORA("Error spawning thread\n", SKYPIAX_P_LOG); - switch_core_session_destroy(&session); - } - } - switch_channel_mark_answered(channel); - - DEBUGA_SKYPE("Here\n", SKYPIAX_P_LOG); - - return 0; -} -int outbound_channel_answered(private_t *tech_pvt) { - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - - if (strlen(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session???\n", SKYPIAX_P_LOG); - } - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No session???\n", SKYPIAX_P_LOG); - } - if (channel) { - switch_channel_mark_answered(channel); - //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); - } else { - ERRORA("No channel???\n", SKYPIAX_P_LOG); - } - - switch_core_session_rwunlock(session); - DEBUGA_SKYPE("HERE!\n", SKYPIAX_P_LOG); - - - return 0; -} - -private_t *find_available_skypiax_interface(void) { - private_t *tech_pvt; - int found = 0; - int i; - - for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { - int skype_state = 0; - - tech_pvt = &globals.SKYPIAX_INTERFACES[i]; - skype_state = tech_pvt->interface_state; - DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", - SKYPIAX_P_LOG, - i, globals.SKYPIAX_INTERFACES[i].name, skype_state); - if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { - found=1; - break; - } - } - } - - if(found) - return tech_pvt; - else - return NULL; + return skypiax_do_skypeapi_thread_func(obj); } + +int dtmf_received(private_t * tech_pvt, char *value) +{ + switch_core_session_t *session = NULL; + switch_channel_t *channel = NULL; + + session = switch_core_session_locate(tech_pvt->session_uuid_str); + channel = switch_core_session_get_channel(session); + + if (channel) { + switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; + DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, + switch_channel_get_name(channel)); + switch_mutex_lock(tech_pvt->flag_mutex); + //FIXME: why sometimes DTMFs from here do not seems to be get by FS? + switch_channel_queue_dtmf(channel, &dtmf); + switch_set_flag(tech_pvt, TFLAG_DTMF); + switch_mutex_unlock(tech_pvt->flag_mutex); + } else { + WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]); + } + switch_core_session_rwunlock(session); + + return 0; +} + +int start_audio_threads(private_t * tech_pvt) +{ + switch_threadattr_t *thd_attr = NULL; + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, + tech_pvt, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, + tech_pvt, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + switch_sleep(100000); + + return 0; +} + +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, NULL)) != 0) { + switch_core_session_add_stream(session, NULL); + channel = switch_core_session_get_channel(session); + skypiax_tech_init(tech_pvt, session); + + if ((tech_pvt->caller_profile = + switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax", + tech_pvt->dialplan, tech_pvt->callid_name, + tech_pvt->callid_number, NULL, NULL, NULL, NULL, + "mod_skypiax", tech_pvt->context, + tech_pvt->destination)) != 0) { + char name[128]; + //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number); + switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name); + switch_channel_set_name(channel, name); + switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); + } + switch_channel_set_state(channel, CS_INIT); + if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { + ERRORA("Error spawning thread\n", SKYPIAX_P_LOG); + switch_core_session_destroy(&session); + } + } + switch_channel_mark_answered(channel); + + DEBUGA_SKYPE("Here\n", SKYPIAX_P_LOG); + + return 0; +} + +int outbound_channel_answered(private_t * tech_pvt) +{ + switch_core_session_t *session = NULL; + switch_channel_t *channel = NULL; + + if (strlen(tech_pvt->session_uuid_str)) { + session = switch_core_session_locate(tech_pvt->session_uuid_str); + } else { + ERRORA("No session???\n", SKYPIAX_P_LOG); + } + if (session) { + channel = switch_core_session_get_channel(session); + } else { + ERRORA("No session???\n", SKYPIAX_P_LOG); + } + if (channel) { + switch_channel_mark_answered(channel); + //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); + } else { + ERRORA("No channel???\n", SKYPIAX_P_LOG); + } + + switch_core_session_rwunlock(session); + DEBUGA_SKYPE("HERE!\n", SKYPIAX_P_LOG); + + return 0; +} + +private_t *find_available_skypiax_interface(void) +{ + private_t *tech_pvt; + int found = 0; + int i; + + for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { + if (strlen(globals.SKYPIAX_INTERFACES[i].name)) { + int skype_state = 0; + + tech_pvt = &globals.SKYPIAX_INTERFACES[i]; + skype_state = tech_pvt->interface_state; + DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", SKYPIAX_P_LOG, i, + globals.SKYPIAX_INTERFACES[i].name, skype_state); + if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) { + found = 1; + break; + } + } + } + + if (found) + return tech_pvt; + else + return NULL; +} + /* For Emacs: * Local Variables: * mode:c Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Thu Feb 12 03:04:35 2009 @@ -208,7 +208,7 @@ #else /* WIN32 */ int audiopipe[2]; int audioskypepipe[2]; - int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ + int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ #endif /* WIN32 */ switch_thread_t *tcp_srv_thread; switch_thread_t *tcp_cli_thread; @@ -246,18 +246,18 @@ int skypiax_skype_call(private_t * tech_pvt, char *idest, int timeout); int skypiax_skype_senddigit(private_t * tech_pvt, char digit); -void * skypiax_do_tcp_srv_thread_func(void *obj); +void *skypiax_do_tcp_srv_thread_func(void *obj); void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj); -void * skypiax_do_tcp_cli_thread_func(void *obj); +void *skypiax_do_tcp_cli_thread_func(void *obj); void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj); -void * skypiax_do_skypeapi_thread_func(void *obj); +void *skypiax_do_skypeapi_thread_func(void *obj); void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj); -int dtmf_received(private_t *tech_pvt, char *value); -int start_audio_threads(private_t *tech_pvt); -int new_inbound_channel(private_t *tech_pvt); -int outbound_channel_answered(private_t *tech_pvt); +int dtmf_received(private_t * tech_pvt, char *value); +int start_audio_threads(private_t * tech_pvt); +int new_inbound_channel(private_t * tech_pvt); +int outbound_channel_answered(private_t * tech_pvt); int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany); Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Thu Feb 12 03:04:35 2009 @@ -61,8 +61,9 @@ return 0; } if (!strncasecmp(message, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n", - SKYPIAX_P_LOG, message); + ERRORA + ("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n", + SKYPIAX_P_LOG, message); tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); tech_pvt->skype_call_id[0] = '\0'; @@ -141,7 +142,7 @@ char msg_to_skype[256]; DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", SKYPIAX_P_LOG, message, obj, id, prop); - //TODO: authomatically flag messages as read based on config param + //TODO: authomatically flag messages as read based on config param sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); skypiax_skype_write(tech_pvt, msg_to_skype); } @@ -207,7 +208,7 @@ char msg_to_skype[1024]; if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) { /* we are not calling out */ - if (!strlen(tech_pvt->skype_call_id)) { + if (!strlen(tech_pvt->skype_call_id)) { /* we are not inside an active call */ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; tech_pvt->interface_state = SKYPIAX_STATE_RING; @@ -229,24 +230,30 @@ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); } else { /* we're owned, we're in a call, let's try to transfer */ - /************************** TODO + /************************** TODO Checking here if it is possible to transfer this call to Test2 -> GET CALL 288 CAN_TRANSFER Test2 <- CALL 288 CAN_TRANSFER test2 TRUE **********************************/ - private_t *available_skypiax_interface; + private_t *available_skypiax_interface; - available_skypiax_interface = find_available_skypiax_interface(); - if(available_skypiax_interface){ - /* there is a skypiax interface idle, let's transfer the call to it */ - DEBUGA_SKYPE ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id); - sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypiax_interface->name); - } else{ - /* no skypiax interfaces idle, let's refuse the call */ - DEBUGA_SKYPE ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - } + available_skypiax_interface = find_available_skypiax_interface(); + if (available_skypiax_interface) { + /* there is a skypiax interface idle, let's transfer the call to it */ + DEBUGA_SKYPE + ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", + SKYPIAX_P_LOG, tech_pvt->skype_call_id, + available_skypiax_interface->name, id); + sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, + available_skypiax_interface->name); + } else { + /* no skypiax interfaces idle, let's refuse the call */ + DEBUGA_SKYPE + ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", + SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); + sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); + } skypiax_skype_write(tech_pvt, msg_to_skype); skypiax_sleep(10000); DEBUGA_SKYPE @@ -268,22 +275,23 @@ 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")) { - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - if(!strcasecmp(tech_pvt->skype_call_id, id)){ - DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPIAX_STATE_DOWN; - } - }else { - DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id); - } + } else if (!strcasecmp(value, "FINISHED")) { + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + if (!strcasecmp(tech_pvt->skype_call_id, id)) { + DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", + SKYPIAX_P_LOG, id); + tech_pvt->skype_call_id[0] = '\0'; + if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + //tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + tech_pvt->interface_state = SKYPIAX_STATE_DOWN; + } + } else { + DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id); + } - } else if (!strcasecmp(value, "CANCELLED")) { + } else if (!strcasecmp(value, "CANCELLED")) { tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; DEBUGA_SKYPE ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", @@ -329,33 +337,35 @@ tech_pvt->interface_state = SKYPIAX_STATE_DIALING; strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; + } else if (!strcasecmp(value, "INPROGRESS")) { + char msg_to_skype[1024]; - if(!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) || !strcasecmp(tech_pvt->skype_call_id, id)){ - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPIAX_STATE_UP; - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, - tech_pvt->tcp_cli_port); - skypiax_skype_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_skype_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); - new_inbound_channel(tech_pvt); - } else { - DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); - outbound_channel_answered(tech_pvt); - } - }else { - DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); - } - } else { + if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) + || !strcasecmp(tech_pvt->skype_call_id, id)) { + tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); + tech_pvt->interface_state = SKYPIAX_STATE_UP; + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, + tech_pvt->tcp_cli_port); + skypiax_skype_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_skype_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); + new_inbound_channel(tech_pvt); + } else { + DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG); + outbound_channel_answered(tech_pvt); + } + } else { + DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", + SKYPIAX_P_LOG, tech_pvt->skype_call_id, id); + } + } else { WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id, value); } @@ -495,7 +505,7 @@ SAMPLES_PER_FRAME * sizeof(short)); if (howmany != SAMPLES_PER_FRAME * sizeof(short)) { ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany, - (int)(SAMPLES_PER_FRAME * sizeof(short))); + (int) (SAMPLES_PER_FRAME * sizeof(short))); } /* done with the stored half frame */ tech_pvt->audiobuf_is_loaded = 0; @@ -593,7 +603,7 @@ if (!running) break; FD_ZERO(&fs); - to.tv_usec = 60000; //60msec + to.tv_usec = 60000; //60msec to.tv_sec = 0; #if defined(WIN32) && !defined(__CYGWIN__) /* on win32 we cannot select from the apr "pipe", so we select on socket writability */ @@ -609,7 +619,6 @@ rt = select(fdselect + 1, &fs, NULL, NULL, &to); #endif - if (rt > 0) { /* read from the pipe the audio frame we are supposed to send out */ got = @@ -617,7 +626,7 @@ SAMPLES_PER_FRAME * sizeof(short)); if (got != SAMPLES_PER_FRAME * sizeof(short)) { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - (int)(SAMPLES_PER_FRAME * sizeof(short))); + (int) (SAMPLES_PER_FRAME * sizeof(short))); } if (got == SAMPLES_PER_FRAME * sizeof(short)) { @@ -641,9 +650,9 @@ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } - /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party*/ + /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */ len = send(fd, (char *) cli_out, got, 0); - skypiax_sleep(5000); //5 msec + skypiax_sleep(5000); //5 msec if (len == -1) { break; @@ -656,15 +665,15 @@ } else { WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, - (int)(SAMPLES_PER_FRAME * sizeof(short))); + (int) (SAMPLES_PER_FRAME * sizeof(short))); } } else { if (rt) ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt); - memset(cli_out, 0, sizeof(cli_out)); - len = send(fd, (char *) cli_out, sizeof(cli_out), 0); - len = send(fd, (char *) cli_out, sizeof(cli_out)/2, 0); - //DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2); + memset(cli_out, 0, sizeof(cli_out)); + len = send(fd, (char *) cli_out, sizeof(cli_out), 0); + len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0); + //DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2); } } @@ -689,7 +698,7 @@ if (samples != SAMPLES_PER_FRAME * sizeof(short)) { if (samples) WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, - (int)(SAMPLES_PER_FRAME * sizeof(short))); + (int) (SAMPLES_PER_FRAME * sizeof(short))); return 0; } else { /* A real frame */ From gmaruzz at freeswitch.org Thu Feb 12 01:09:29 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 03:09:29 -0600 Subject: [Freeswitch-branches] [commit] r11918 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Feb 12 03:09:29 2009 New Revision: 11918 Log: skypiax: cleaning on Visual C Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Thu Feb 12 03:09:29 2009 @@ -1164,7 +1164,7 @@ private_t *find_available_skypiax_interface(void) { - private_t *tech_pvt; + private_t *tech_pvt=NULL; int found = 0; int i; From gmaruzz at freeswitch.org Thu Feb 12 03:32:11 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 05:32:11 -0600 Subject: [Freeswitch-branches] [commit] r11919 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk Message-ID: Author: gmaruzz Date: Thu Feb 12 05:32:11 2009 New Revision: 11919 Log: skypiax: outbound interface automatic selection for * too: you can call skypiax/ANY/another_skypename, it will automatically chose first available channel. Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Thu Feb 12 05:32:11 2009 @@ -285,6 +285,7 @@ struct skypiax_pvt *p = NULL; struct ast_channel *tmp = NULL; char *name = data; + int found = 0; DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format); @@ -298,9 +299,28 @@ LOKKA(&skypiax_iflock); /* make a pointer to the first interface in the interfaces list */ p = skypiax_iflist; + + + if (strncmp("ANY", name, 3) == 0) { + /* we've been asked for the "ANY" interface, let's find the first idle interface */ + DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG); + p = find_available_skypiax_interface(); + if (p){ + found = 1; + + /* create a new channel owning this interface */ + tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context); + if (!tmp) { + /* the channel was not created, probable memory allocation error */ + *cause = AST_CAUSE_SWITCH_CONGESTION; + } + + } + + } + /* Search for the requested interface and verify if is unowned and format compatible */ - //TODO implement groups a la chan_zap - while (p) { + while (p && !found) { size_t length = strlen(p->name); /* is this the requested interface? */ if (strncmp(name, p->name, length) == 0) { @@ -870,7 +890,7 @@ i++; } if (p->SkypiaxHandles.api_connected) { - NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name); + NOTICA("STARTED interface %s\n", SKYPIAX_P_LOG, p->name); } else { ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); running = 0; From gmaruzz at freeswitch.org Thu Feb 12 03:33:25 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 05:33:25 -0600 Subject: [Freeswitch-branches] [commit] r11920 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Feb 12 05:33:25 2009 New Revision: 11920 Log: skypiax: cleaning on Visual C Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Thu Feb 12 05:33:25 2009 @@ -1002,7 +1002,7 @@ if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_skypeapi_thread) { #ifdef WIN32 if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypiax_skypeapi_thread_func die - ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); + DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPIAX_P_LOG, GetLastError()); } #else XEvent e; From gmaruzz at freeswitch.org Thu Feb 12 06:46:51 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 12 Feb 2009 08:46:51 -0600 Subject: [Freeswitch-branches] [commit] r11922 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk configs Message-ID: Author: gmaruzz Date: Thu Feb 12 08:46:51 2009 New Revision: 11922 Log: skypiax: cleaning Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/configs/skypiax.conf.xml freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Thu Feb 12 08:46:51 2009 @@ -385,7 +385,7 @@ DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id); //sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", p->skype_call_id); sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id); - skypiax_skype_write(p, msg_to_skype); + skypiax_signaling_write(p, msg_to_skype); } while (p->interface_state != SKYPIAX_STATE_DOWN) { @@ -490,7 +490,7 @@ sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit); - skypiax_skype_write(p, msg_to_skype); + skypiax_signaling_write(p, msg_to_skype); return 0; } @@ -504,7 +504,7 @@ sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit); - skypiax_skype_write(p, msg_to_skype); + skypiax_signaling_write(p, msg_to_skype); return 0; } @@ -1477,7 +1477,7 @@ if (p->skype) { if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds)) { - res = skypiax_skype_read(p); + res = skypiax_signaling_read(p); if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) { //ast_log(LOG_NOTICE, "CALLFLOW_INCOMING_RING SKYPE\n"); DEBUGA_SKYPE("CALLFLOW_INCOMING_RING\n", SKYPIAX_P_LOG); @@ -1569,7 +1569,7 @@ usleep(1000); pthread_testcancel(); if (p->skype) { - res = skypiax_skype_read(p); + res = skypiax_signaling_read(p); if (res == CALLFLOW_INCOMING_HANGUP) { DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); if (p->owner) { @@ -1951,7 +1951,7 @@ if (c == 1023) break; } - skypiax_skype_write(p, skype_msg); + skypiax_signaling_write(p, skype_msg); return RESULT_SUCCESS; } @@ -2074,7 +2074,7 @@ p->skype_friends[0] = '\0'; sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); - if (skypiax_skype_write(p, msg_to_skype) < 0) { + if (skypiax_signaling_write(p, msg_to_skype) < 0) { return -1; } @@ -2116,7 +2116,7 @@ p->skype_displayname[0] = '\0'; sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); - skypiax_skype_write(p, msg_to_skype); + skypiax_signaling_write(p, msg_to_skype); int displayname_count = 0; while (p->skype_displayname[0] == '\0') { /* FIXME needs a timeout, can't wait forever! @@ -2198,7 +2198,7 @@ p->skype_fullname[0] = '\0'; sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); - skypiax_skype_write(p, msg_to_skype); + skypiax_signaling_write(p, msg_to_skype); int fullname_count = 0; while (p->skype_fullname[0] == '\0') { /* FIXME needs a timeout, can't wait forever! Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Thu Feb 12 08:46:51 2009 @@ -317,8 +317,8 @@ //int skypiax2skype(struct ast_channel *c, void *data); //int skype2skypiax(struct ast_channel *c, void *data); //void skypiax_skype_disconnect(void); -int skypiax_skype_write(struct skypiax_pvt *p, char *msg_to_skype); -int skypiax_skype_read(struct skypiax_pvt *p); +int skypiax_signaling_write(struct skypiax_pvt *p, char *msg_to_skype); +int skypiax_signaling_read(struct skypiax_pvt *p); int skypiax_console_skype(int fd, int argc, char *argv[]); #ifdef WANT_SKYPE_X11 int X11_errors_handler(Display * dpy, XErrorEvent * err); @@ -403,7 +403,7 @@ int new_inbound_channel(private_t * tech_pvt); int outbound_channel_answered(private_t * tech_pvt); int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit); -int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype); +int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype); #if defined(WIN32) && !defined(__CYGWIN__) int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany); int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany); Modified: freeswitch/branches/gmaruzz/mod_skypiax/configs/skypiax.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/configs/skypiax.conf.xml (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/configs/skypiax.conf.xml Thu Feb 12 08:46:51 2009 @@ -4,7 +4,6 @@ - @@ -19,6 +18,7 @@ + @@ -28,6 +28,7 @@ + From gmaruzz at freeswitch.org Mon Feb 16 10:57:51 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 16 Feb 2009 12:57:51 -0600 Subject: [Freeswitch-branches] [commit] r12063 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Feb 16 12:57:51 2009 New Revision: 12063 Log: skypiax: added MPL license to mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 16 12:57:51 2009 @@ -1,3 +1,39 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * This module (mod_skypiax) has been contributed by: + * + * Giovanni Maruzzelli (gmaruzz at gmail.com) + * + * + * Further Contributors: + * + * + * + * mod_skypiax.c -- Skype compatible Endpoint Module + * + */ + #include "skypiax.h" SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); From brian at freeswitch.org Thu Feb 19 12:57:37 2009 From: brian at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Feb 2009 14:57:37 -0600 Subject: [Freeswitch-branches] [commit] r12167 - in freeswitch: branches/gmaruzz/mod_skypiax trunk/src/mod/endpoints/mod_skypiax Message-ID: Author: brian Date: Thu Feb 19 14:57:36 2009 New Revision: 12167 Log: Move Skypiax into svn Trunk Removed: freeswitch/branches/gmaruzz/mod_skypiax/ Changes in other areas also in this revision: Added: freeswitch/trunk/src/mod/endpoints/mod_skypiax/ - copied from r12166, /freeswitch/branches/gmaruzz/mod_skypiax/ From gmaruzz at freeswitch.org Thu Feb 19 13:41:17 2009 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 19 Feb 2009 15:41:17 -0600 Subject: [Freeswitch-branches] [commit] r12170 - freeswitch/branches/gmaruzz/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Feb 19 15:41:17 2009 New Revision: 12170 Log: skypiax: Yay, on trunk! modified README Added: freeswitch/branches/gmaruzz/mod_skypiax/ freeswitch/branches/gmaruzz/mod_skypiax/README Added: freeswitch/branches/gmaruzz/mod_skypiax/README ============================================================================== --- (empty file) +++ freeswitch/branches/gmaruzz/mod_skypiax/README Thu Feb 19 15:41:17 2009 @@ -0,0 +1,6 @@ +You can find skypiax in the mainline FreeSWITCH svn: + +svn co http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/endpoints/mod_skypiax \ + mod_skypiax + + From ctrix at freeswitch.org Sun Feb 22 04:26:26 2009 From: ctrix at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Feb 2009 06:26:26 -0600 Subject: [Freeswitch-branches] [commit] r12231 - freeswitch/branches/ctrix/mod_airpe Message-ID: Author: ctrix Date: Sun Feb 22 06:26:26 2009 New Revision: 12231 Log: always return success when reading Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_common.c Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_common.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/airpe_if_common.c (original) +++ freeswitch/branches/ctrix/mod_airpe/airpe_if_common.c Sun Feb 22 06:26:26 2009 @@ -256,7 +256,7 @@ assert(pvt->airpe); if ( !switch_test_flag(pvt, TFLAG_IO) ) { - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } airpe = pvt->airpe; @@ -327,8 +327,11 @@ if ( (rv==SWITCH_STATUS_SUCCESS) ) { pvt->read_frame.datalen = mlen; } + else { + pvt->read_frame.datalen = 0; + } - return rv; + return SWITCH_STATUS_SUCCESS; } /***************************************************************************** From ctrix at freeswitch.org Sun Feb 22 04:27:47 2009 From: ctrix at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Feb 2009 06:27:47 -0600 Subject: [Freeswitch-branches] [commit] r12232 - freeswitch/branches/ctrix/mod_airpe Message-ID: Author: ctrix Date: Sun Feb 22 06:27:47 2009 New Revision: 12232 Log: fix warnings Modified: freeswitch/branches/ctrix/mod_airpe/mod_airpe.c Modified: freeswitch/branches/ctrix/mod_airpe/mod_airpe.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/mod_airpe.c (original) +++ freeswitch/branches/ctrix/mod_airpe/mod_airpe.c Sun Feb 22 06:27:47 2009 @@ -118,7 +118,7 @@ switch_socket_t *new_sock = NULL; switch_sockaddr_t *sa; - rv = switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, airpe_module_pool); + rv = switch_sockaddr_info_get(&sa, host, AF_INET, (switch_port_t) port, 0, airpe_module_pool); if ( rv != SWITCH_STATUS_SUCCESS ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Creation Error! (1)\n"); return NULL; @@ -200,7 +200,7 @@ airpe_audio_sockets_create(airpe); switch_threadattr_create(&attr_skype, airpe_module_pool); - switch_threadattr_detach_set(&attr_skype, 0); + switch_threadattr_detach_set(attr_skype, 0); switch_threadattr_stacksize_set(attr_skype, SWITCH_THREAD_STACKSIZE); return switch_thread_create(&airpe->airpe_thread_skype, @@ -874,8 +874,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_airpe_load) { - airpe_module_pool = pool; - switch_status_t ret; + switch_status_t ret; + airpe_module_pool = (switch_memory_pool_t *) pool; + memset(&globals, 0, sizeof(globals)); From ctrix at freeswitch.org Sun Feb 22 04:28:30 2009 From: ctrix at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Feb 2009 06:28:30 -0600 Subject: [Freeswitch-branches] [commit] r12233 - freeswitch/branches/ctrix/mod_airpe Message-ID: Author: ctrix Date: Sun Feb 22 06:28:30 2009 New Revision: 12233 Log: something for windows Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c (original) +++ freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c Sun Feb 22 06:28:30 2009 @@ -1,19 +1,315 @@ - -#include "mod_airpe.h" - -#ifdef WIN32 - -#error WIN32 Not yet supported - -#endif - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: - */ + +#include "mod_airpe.h" + +#ifdef WIN32 + +//#error WIN32 Not yet supported + +#include +#include +#include +#include + +#include +#include + + +enum { + SKYPECONTROLAPI_ATTACH_SUCCESS = 0, // Client is successfully attached and API window handle can be found in wParam parameter + SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, // Skype has acknowledged connection request and is waiting for confirmation from the user. + // The client is not yet attached and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message + SKYPECONTROLAPI_ATTACH_REFUSED = 2, // User has explicitly denied access to client + SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, // API is not available at the moment. For example, this happens when no user is currently logged in. + // Client should wait for SKYPECONTROLAPI_ATTACH_API_AVAILABLE broadcast before making any further + // connection attempts. + SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 +}; + + + + +UINT uiGlobal_MsgID_SkypeControlAPIAttach; +UINT uiGlobal_MsgID_SkypeControlAPIDiscover; +HINSTANCE hInit_ProcessHandle; +HWND hInit_MainWindowHandle; +char acInit_WindowClassName[128]; +HANDLE hGlobal_ThreadShutdownEvent; +HWND hGlobal_SkypeAPIWindowHandle=NULL; + + +struct skype_window_handler_s { + uint8_t api_connected; + int watchdog; +}; + +static switch_memory_pool_t *tech_pool; + + +void airpe_tech_set_pool(switch_memory_pool_t *pool) { + if ( !tech_pool ) + tech_pool = pool; + + ADEBUG("--\n"); +} + +switch_status_t airpe_skype_watchdog_reset(skype_window_handler_t *window) { + window->watchdog = 0; + ADEBUG("--\n"); + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t airpe_skype_watchdog_increment(skype_window_handler_t *window) { + window->watchdog++; + + ADEBUG("--\n"); + if ( window->watchdog >= 5 ) { + } + + return SWITCH_STATUS_SUCCESS; +} + +skype_window_handler_t *skype_window_alloc( switch_memory_pool_t *pool) { + ADEBUG("--\n"); + return (skype_window_handler_t *) switch_core_alloc( pool, sizeof(skype_window_handler_t)); +} + +switch_status_t skype_restart( skype_window_handler_t *window, const char *params ) { + /* TODO */ + ADEBUG("--\n"); + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t airpe_skype_send_message(skype_window_handler_t *window, const char *message_P) { + COPYDATASTRUCT oCopyData; + ADEBUG("Sending %s \n", message_P); + + oCopyData.dwData=0; + oCopyData.lpData=(char*) message_P; + oCopyData.cbData=strlen(message_P)+1; + + if( oCopyData.cbData!=1 ) { + if( SendMessage( hGlobal_SkypeAPIWindowHandle, WM_COPYDATA, (WPARAM)hInit_MainWindowHandle, (LPARAM)&oCopyData)==FALSE ) { + hGlobal_SkypeAPIWindowHandle=NULL; + ADEBUG("DISCONNECTED :-( \n"); + } + } + + return SWITCH_STATUS_SUCCESS; +} + +switch_status_t airpe_skype_avalaible(skype_window_handler_t *window) +{ + ADEBUG("--\n"); + return SWITCH_STATUS_SUCCESS; +} + +/***************************************************************************** + THREADS + *****************************************************************************/ +static int attached = -1; + +static LRESULT APIENTRY SkypeReceiveMessage( HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam) { + LRESULT lReturnCode; + int fIssueDefProc; + airpe_interface_t *airpe = NULL; + + ADEBUG("--\n"); + + lReturnCode=0; + fIssueDefProc=0; + + airpe = (airpe_interface_t *) GetWindowLong(hWindow, GWL_USERDATA); + + switch(uiMessage) { + case WM_CREATE: + assert(!airpe); + airpe = (airpe_interface_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; + SetWindowLong(hWindow, GWL_USERDATA, (LONG) airpe); + break; + case WM_DESTROY: + hInit_MainWindowHandle=NULL; + PostQuitMessage(0); + break; + case WM_COPYDATA: + if( hGlobal_SkypeAPIWindowHandle==(HWND)uiParam ) { + char msg[SKYPE_MSG_LEN]; + + PCOPYDATASTRUCT poCopyData=(PCOPYDATASTRUCT)ulParam; + strncpy(msg, (const char *) poCopyData->lpData, sizeof(msg)-1); + ADEBUG("MESSAGE: %s\n", msg); + airpe_manage_skype_msg( airpe, msg); + //printf( "Message from Skype(%u): %.*s\n", poCopyData->dwData, poCopyData->cbData, poCopyData->lpData); + lReturnCode=1; + } + break; + default: + if( uiMessage==uiGlobal_MsgID_SkypeControlAPIAttach ) { + switch(ulParam) { + case SKYPECONTROLAPI_ATTACH_SUCCESS: + printf("!!! Connected\n"); + hGlobal_SkypeAPIWindowHandle=(HWND)uiParam; + break; + case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: + printf("!!! Pending authorization\n"); + break; + case SKYPECONTROLAPI_ATTACH_REFUSED: + printf("!!! Connection refused\n"); + break; + case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: + printf("!!! Skype API not available\n"); + break; + case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: + printf("!!! Try connect now (API available); issue #connect\n"); + break; + } + lReturnCode=1; + break; + } + fIssueDefProc=1; + break; + } + + if( fIssueDefProc ) { + lReturnCode=DefWindowProc( hWindow, uiMessage, uiParam, ulParam); + } + + return(lReturnCode); +} + +static switch_status_t Initialize_CreateMainWindow(airpe_interface_t *airpe) { + hInit_MainWindowHandle=CreateWindowEx( + WS_EX_APPWINDOW|WS_EX_WINDOWEDGE, + acInit_WindowClassName, "", + WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX, + CW_USEDEFAULT, CW_USEDEFAULT, 128, 128, NULL, 0, hInit_ProcessHandle, + airpe); + + if ( hInit_MainWindowHandle!=NULL ) { + return SWITCH_STATUS_SUCCESS; + } + else { + return SWITCH_STATUS_FALSE; + } +} + +void DeInitialize_DestroyMainWindow(void) { + if( hInit_MainWindowHandle!=NULL ) + DestroyWindow(hInit_MainWindowHandle),hInit_MainWindowHandle=NULL; + } + + +static switch_status_t Initialize_CreateWindowClass(void) { + unsigned char *paucUUIDString; + RPC_STATUS lUUIDResult; + int fReturnStatus; + UUID oUUID; + + fReturnStatus=0; + lUUIDResult = UuidCreate(&oUUID); + + hInit_ProcessHandle = (HINSTANCE) OpenProcess( PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); + + if( hInit_ProcessHandle!=NULL && (lUUIDResult==RPC_S_OK || lUUIDResult==RPC_S_UUID_LOCAL_ONLY) ) { + if( UuidToString( &oUUID, &paucUUIDString)==RPC_S_OK ) { + WNDCLASS oWindowClass; + + strcpy( acInit_WindowClassName, "mod_airpe"); + strcat( acInit_WindowClassName, (char *)paucUUIDString); + + oWindowClass.style=CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS; + oWindowClass.lpfnWndProc=(WNDPROC)&SkypeReceiveMessage; + oWindowClass.cbClsExtra=0; + oWindowClass.cbWndExtra=0; + oWindowClass.hInstance=hInit_ProcessHandle; + oWindowClass.hIcon=NULL; + oWindowClass.hCursor=NULL; + oWindowClass.hbrBackground=NULL; + oWindowClass.lpszMenuName=NULL; + oWindowClass.lpszClassName=acInit_WindowClassName; + + if( RegisterClass(&oWindowClass)!=0 ) + fReturnStatus=1; + + RpcStringFree(&paucUUIDString); + } + } + if( fReturnStatus==0 ) { + CloseHandle(hInit_ProcessHandle),hInit_ProcessHandle=NULL; + return SWITCH_STATUS_FALSE; + } + else { + return SWITCH_STATUS_SUCCESS; + } +} + +static void DeInitialize_DestroyWindowClass(void) { + UnregisterClass( acInit_WindowClassName, hInit_ProcessHandle); + CloseHandle(hInit_ProcessHandle),hInit_ProcessHandle=NULL; +} + +void *SWITCH_THREAD_FUNC airpe_skype_thread(switch_thread_t * thread, void *obj) { + airpe_interface_t *airpe = NULL; + + assert(obj); + airpe = obj; + + uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); + uiGlobal_MsgID_SkypeControlAPIDiscover = RegisterWindowMessage("SkypeControlAPIDiscover"); + + if( uiGlobal_MsgID_SkypeControlAPIAttach == 0 || uiGlobal_MsgID_SkypeControlAPIDiscover == 0 ) { + ADEBUG("Cannot find any running Skype application\n"); + return NULL; + } + + if( Initialize_CreateWindowClass()==SWITCH_STATUS_SUCCESS ) { + if( Initialize_CreateMainWindow(airpe)==SWITCH_STATUS_SUCCESS ) { + hGlobal_ThreadShutdownEvent = CreateEvent( NULL, TRUE, FALSE, NULL); + if( hGlobal_ThreadShutdownEvent!=NULL ) { + if( SendMessage( HWND_BROADCAST, uiGlobal_MsgID_SkypeControlAPIDiscover, (WPARAM)hInit_MainWindowHandle, 0)!=0 ) { + MSG oMessage; + + airpe->running = 1; + + if ( airpe_on_connect_messages( airpe, 6 ) != SWITCH_STATUS_SUCCESS ) { + switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "airpe client %s. Failed to send handshake messages\n", + airpe->name); + airpe->running = 0; + } + + ADEBUG("BEFORE LOOPING--\n"); + while( airpe->running && GetMessage( &oMessage, 0, 0, 0)!=FALSE ) { + ADEBUG("LOOPING\n"); + switch_sleep(100000); + TranslateMessage(&oMessage); + DispatchMessage(&oMessage); + } +// WaitForSingleObject( hGlobal_ThreadShutdownEvent, INFINITE); + } + CloseHandle(hGlobal_ThreadShutdownEvent); + } + DeInitialize_DestroyMainWindow(); + } + DeInitialize_DestroyWindowClass(); + } + + ADEBUG("Exiting\n"); + airpe->airpe_thread_skype = NULL; + + return NULL; +} + + + +#endif + +/* For Emacs: + * Local Variables: + * mode:c + * indent-tabs-mode:t + * tab-width:4 + * c-basic-offset:4 + * End: + * For VIM: + * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: + */ From ctrix at freeswitch.org Sun Feb 22 04:29:00 2009 From: ctrix at freeswitch.org (FreeSWITCH SVN) Date: Sun, 22 Feb 2009 06:29:00 -0600 Subject: [Freeswitch-branches] [commit] r12234 - freeswitch/branches/ctrix/mod_airpe Message-ID: Author: ctrix Date: Sun Feb 22 06:29:00 2009 New Revision: 12234 Log: and the project as well Added: freeswitch/branches/ctrix/mod_airpe/mod_airpe.2008.vcproj Added: freeswitch/branches/ctrix/mod_airpe/mod_airpe.2008.vcproj ============================================================================== --- (empty file) +++ freeswitch/branches/ctrix/mod_airpe/mod_airpe.2008.vcproj Sun Feb 22 06:29:00 2009 @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ctrix at freeswitch.org Mon Feb 23 02:42:34 2009 From: ctrix at freeswitch.org (FreeSWITCH SVN) Date: Mon, 23 Feb 2009 04:42:34 -0600 Subject: [Freeswitch-branches] [commit] r12242 - freeswitch/branches/ctrix/mod_airpe Message-ID: Author: ctrix Date: Mon Feb 23 04:42:34 2009 New Revision: 12242 Log: Shutdown function for each interface Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c freeswitch/branches/ctrix/mod_airpe/mod_airpe.h Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c (original) +++ freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c Mon Feb 23 04:42:34 2009 @@ -69,6 +69,10 @@ } } +switch_status_t airpe_interface_shutdown(airpe_interface_t *airpe) { + return SWITCH_STATUS_SUCCESS; +} + /***************************************************************************** THREADS *****************************************************************************/ Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c (original) +++ freeswitch/branches/ctrix/mod_airpe/airpe_if_win32.c Mon Feb 23 04:42:34 2009 @@ -103,6 +103,10 @@ return SWITCH_STATUS_SUCCESS; } +switch_status_t airpe_interface_shutdown(airpe_interface_t *airpe) { + return SWITCH_STATUS_SUCCESS; +} + /***************************************************************************** THREADS *****************************************************************************/ Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c (original) +++ freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c Mon Feb 23 04:42:34 2009 @@ -212,7 +212,9 @@ return SWITCH_STATUS_SUCCESS; } - +switch_status_t airpe_interface_shutdown(airpe_interface_t *airpe) { + return SWITCH_STATUS_SUCCESS; +} /***************************************************************************** THREADS Modified: freeswitch/branches/ctrix/mod_airpe/mod_airpe.h ============================================================================== --- freeswitch/branches/ctrix/mod_airpe/mod_airpe.h (original) +++ freeswitch/branches/ctrix/mod_airpe/mod_airpe.h Mon Feb 23 04:42:34 2009 @@ -232,6 +232,8 @@ switch_status_t airpe_skype_avalaible(skype_window_handler_t *window); switch_status_t skype_restart( skype_window_handler_t *airpe, const char *params ); switch_status_t airpe_skype_send_message(skype_window_handler_t *window, const char *message_P); +switch_status_t airpe_interface_shutdown(airpe_interface_t *airpe); + void *SWITCH_THREAD_FUNC airpe_skype_thread(switch_thread_t * thread, void *obj); /* For Emacs: