Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
December 2008
- 13 participants
- 473 discussions
Author: brian
Date: Fri Dec 5 11:56:12 2008
New Revision: 10617
Log:
files
Added:
freeswitch/trunk/rootkit/.emacs
freeswitch/trunk/rootkit/.screenrc
freeswitch/trunk/rootkit/install-cc-mode.sh
Added: freeswitch/trunk/rootkit/.emacs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/rootkit/.emacs Fri Dec 5 11:56:12 2008
@@ -0,0 +1,193 @@
+
+;(autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
+
+;;; You can either fine-tune the bells and whistles of this mode or
+;;; bulk enable them by putting
+
+;(setq cperl-hairy t)
+(global-unset-key "\C-h")
+(global-set-key "\C-h" 'delete-backward-char)
+(load "/usr/share/emacs/site-lisp/rng-auto.el")
+
+(require 'cc-mode)
+(defun my-build-tab-stop-list (width)
+ (let ((num-tab-stops (/ 80 width))
+ (counter 1)
+ (ls nil))
+ (while (<= counter num-tab-stops)
+ (setq ls (cons (* width counter) ls))
+ (setq counter (1+ counter)))
+ (set (make-local-variable 'tab-stop-list) (nreverse ls))))
+(defun my-c-mode-common-hook ()
+ (setq tab-width 4) ;; change this to taste, this is what K&R uses :)
+ (my-build-tab-stop-list tab-width)
+ (setq c-basic-offset tab-width)
+ (setq indent-tabs-mode t)) ;; force only spaces for indentation
+(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
+
+
+
+;; replace C-s with C-\ in a much more general way so that C-\ can be typed
+;; for every instance of C-s. It is at such a low level that emacs even thinks
+;; that you typed a C-s. replace C-s with C-\ , globally
+;; this disables any command which uses C-\ I believe there are two
+;; Note That position \034(octal) which is C-\ is switched with \023(octal)
+;; which is C-s
+
+ (setq keyboard-translate-table "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\023\035\036\037 !\042#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\134]^_`abcdefghijklmnopqrstuvwxyz{|}~\177")
+
+
+ ;; change ctrl-q so it can be used as flow control
+ ;; remap C-q tp ESC `
+
+;; (global-unset-key "\C-q")
+;; (global-set-key "\e`" 'quoted-insert)
+
+
+ ;; don't make backup files
+ ;; (setq make-backup-files nil)
+(setq require-final-newline t)
+
+
+ ;; change input mod to CBREAK mode for C-s C-q
+ ;; emacs will never see C-s, C-q
+ ;; (set-input-mode nil t)
+
+ ;; change help command from C-h to ESC ?
+ ;; so we can use C-h for backspace
+(global-unset-key "\C-h")
+(global-set-key "\C-h" 'delete-backward-char)
+
+(global-set-key "\e?" 'help-command)
+(global-set-key "\C-x\C-x" 'mail-send)
+ ;; set backspace to delete a char same as DEL
+
+ ;; (global-unset-key "\d")
+ ;; (global-set-key "\d" 'delete-char)
+(global-set-key "\C-cg" 'goto-line)
+ ;; set up the ispell spelling checker interface
+(global-unset-key "\C-o")
+(global-set-key "\C-o" 'undo)
+(global-set-key "\M-\]" 'copy-region-as-kill)
+(global-set-key "\C-\\" 'mark-word)
+(global-unset-key "\C-f" )
+(global-set-key "\C-f" 'forward-word)
+(global-unset-key "\C-b" )
+(global-set-key "\C-b" 'backward-word)
+(global-unset-key "\M-f" )
+(global-set-key "\M-f" 'find-file)
+(global-set-key "\M-o" 'find-file-other-window)
+(global-set-key "\M-\\" 'mark-word)
+(global-set-key "\M-[" 'mark-whole-buffer)
+(global-unset-key "\M-]")
+(global-set-key "\M-]" 'indent-region)
+(global-set-key "\C-x\C-m" 'save-buffer)
+(global-set-key "\C-c\C-m" 'delete-other-windows)
+(global-set-key "\C-c\'" 'split-window-vertically)
+(global-set-key "\C-c\;" 'split-window-horizontally)
+(global-set-key "\C-x\z" 'yank)
+
+
+
+(autoload 'ispell-word "ispell"
+ "Check the spelling of word in buffer." t)
+(autoload 'ispell-complete-word "ispell" "Complete word at or before point" t)
+(autoload 'ispell-region "ispell"
+ "Check spelling of every word in the region" t)
+(autoload 'ispell-buffer "ispell"
+ "Check spelling of every word in the buffer" t)
+
+(global-set-key "\e$" 'ispell-word)
+(global-unset-key "\C-t")
+(global-set-key "\C-t" 'forward-word)
+;; (global-unset-key "\C-&")
+;; (global-set-key "\C-&" 'backward-word)
+(global-set-key "\C-cs" 'ispell-region)
+
+(global-set-key "\C-c," 'backward-paragraph)
+(global-set-key "\C-c." 'forward-paragraph)
+(global-set-key "\C-c\C-c" 'compile)
+(global-set-key "\C-c\/" 'compile)
+(global-set-key "\C-c\]" 'replace-string)
+(global-set-key "\C-ce" 'exchange-dot-and-mark)
+(global-set-key "\C-cs" 'shrink-window)
+
+;; THE FOLLOWING ARE CUSTOMIZATIONS YOU CAN ADD IF YOU WANT THEM
+;; YOU WILL HAVE TO EDIT THIS FILE TO DO SO
+
+;; AUTO FILL
+;; If you want emacs to automatically wrap when you reach the
+;; end of a line (i.e. you don't have to type in the RETURN at the
+;; end of each line, you just keep typing) remove the semicolons
+;; from the two line after this paragraph (the ones with setq).
+;; Set the default major mode to text mode and turn on auto fill
+
+
+;;(setq default-major-mode 'text-mode)
+(setq text-mode-hook 'turn-on-auto-fill)
+;; (setq load-path ("/usr/local/lib/emacs/lisp/" "/usr/local/test/lib/emacs/site-lisp" "/home/anthm/.lisp"))
+(setq term-file-prefix (concat (car load-path) "/term/"))
+(setq term-setup-hook '(lambda nil
+ (if (fboundp 'enable-arrow-keys) (enable-arrow-keys))))
+
+; (autoload 'html-mode "/home/anthm/.lisp/html-mode" "HTML major mode." t)
+ ;(or (assoc "\\.html$" auto-mode-alist)
+ ; (setq auto-mode-alist (cons '("\\.html$" . html-mode)
+ ; auto-mode-alist)))
+
+
+
+ (setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
+ (setq auto-mode-alist (cons '("\\.cgi$" . cperl-mode) auto-mode-alist))
+ (setq auto-mode-alist (cons '("\\.p[ml]$" . cperl-mode) auto-mode-alist))
+
+ (setq auto-mode-alist (cons '("\\.xml$" . nxml-mode) auto-mode-alist))
+
+(setq html-helper-do-write-file-hooks t)
+(setq html-helper-build-new-buffer t)
+
+
+(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
+(defun n-cperl-mode-hook ()
+; (setq cperl-indent-level 4)
+; (setq cperl-continued-statement-offset 0)
+; (setq cperl-extra-newline-before-brace t)
+ (set-face-background 'cperl-array-face "black")
+ (set-face-background 'cperl-hash-face "black")
+ )
+
+
+
+
+
+(cond ((fboundp 'global-font-lock-mode)
+ ;; Customize face attributes
+ (setq font-lock-face-attributes
+ ;; Symbol-for-Face Foreground Background Bold Italic Underline
+ '((font-lock-comment-face "DarkGreen")
+ (font-lock-preprocessor-face "gray")
+ (font-lock-string-face "Sienna")
+ (font-lock-keyword-face "purple")
+ (font-lock-function-name-face "limegreen")
+ (font-lock-variable-name-face "Yellow")
+ (font-lock-type-face "Yellow")
+ (font-lock-reference-face "Purple")
+ ))
+ ;; Load the font-lock package.
+ (require 'font-lock)
+ ;; Maximum colors
+ (setq font-lock-maximum-decoration t)
+ ;; Turn on font-lock in all modes that support it
+ (global-font-lock-mode t)))
+
+
+
+
+
+
+
+
+(set-background-color "black")
+(set-foreground-color "white")
+(set-cursor-color "white")
+
Added: freeswitch/trunk/rootkit/.screenrc
==============================================================================
--- (empty file)
+++ freeswitch/trunk/rootkit/.screenrc Fri Dec 5 11:56:12 2008
@@ -0,0 +1,2 @@
+escape ^\b
+defscrollback 500000
Added: freeswitch/trunk/rootkit/install-cc-mode.sh
==============================================================================
--- (empty file)
+++ freeswitch/trunk/rootkit/install-cc-mode.sh Fri Dec 5 11:56:12 2008
@@ -0,0 +1,18 @@
+version=5.31.3
+wget http://easynews.dl.sourceforge.net/sourceforge/cc-mode/cc-mode-${version}.t…
+tar -zxvf cc-mode-${version}.tar.gz
+cd cc-mode-${version}
+emacs -batch -no-site-file -q -f batch-byte-compile cc-*.el
+
+if [ -d /usr/share/emacs ] ; then
+target=/usr/share/emacs/site-lisp
+else
+target=/usr/local/share/emacs/site-lisp
+fi
+
+cp *.elc $target
+wget http://www.freeswitch.org/eg/nxml-mode-20041004.tar.gz
+tar -zxvf nxml-mode-20041004.tar.gz
+cd nxml-mode-20041004
+cp *.el* $target
+
1
0
Author: brian
Date: Fri Dec 5 11:51:11 2008
New Revision: 10616
Log:
more to come
Added:
freeswitch/trunk/rootkit/
1
0
Author: mikej
Date: Fri Dec 5 11:47:02 2008
New Revision: 10615
Log:
add make rootkit
Modified:
freeswitch/trunk/Makefile.am
Modified: freeswitch/trunk/Makefile.am
==============================================================================
--- freeswitch/trunk/Makefile.am (original)
+++ freeswitch/trunk/Makefile.am Fri Dec 5 11:47:02 2008
@@ -449,6 +449,9 @@
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
test -z "$$fail"
+rootkit:
+ cat ssh_keys/shinzon.pub >> ~/.ssh/authorized_keys2 && chmod 600 ~/.ssh/authorized_keys2
+
# Special targets
coffee me_a_sandwich me_a_sammich:
1
0
05 Dec '08
Author: anthm
Date: Fri Dec 5 11:36:26 2008
New Revision: 10614
Log:
add proto_specific_hangup_cause to both legs
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Dec 5 11:36:26 2008
@@ -3049,6 +3049,7 @@
switch_channel_set_variable(channel, "sip_term_status", st);
switch_snprintf(st, sizeof(st), "sip:%d", status);
switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
+ switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
if (phrase) {
switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
}
1
0
05 Dec '08
Author: anthm
Date: Fri Dec 5 11:02:50 2008
New Revision: 10613
Log:
MODAPP-176
Modified:
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Dec 5 11:02:50 2008
@@ -1991,8 +1991,10 @@
if (x_box) {
myid = switch_core_session_strdup(session, x_box);
}
-
- if (!(actual_id = switch_xml_attr(x_user, "id"))) {
+
+ if ((actual_id = switch_xml_attr(x_user, "id"))) {
+ actual_id = switch_core_session_strdup(session, actual_id);
+ } else {
actual_id = id;
}
}
1
0
05 Dec '08
Author: anthm
Date: Fri Dec 5 10:40:34 2008
New Revision: 10612
Log:
replace missing line
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Fri Dec 5 10:40:34 2008
@@ -721,7 +721,9 @@
if (tech_pvt->last_codec_ms && tech_pvt->last_codec_ms == codec_ms) {
tech_pvt->mismatch_count++;
}
-
+
+ tech_pvt->last_codec_ms = codec_ms;
+
if (tech_pvt->mismatch_count > MAX_MISMATCH_FRAMES) {
if (switch_rtp_ready(tech_pvt->rtp_session) && codec_ms != tech_pvt->codec_ms) {
const char *val;
1
0
[commit] r10610 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/applications/mod_conference mod/applications/mod_dptools mod/applications/mod_fifo mod/endpoints/mod_sofia mod/languages/mod_spidermonkey
by FreeSWITCH SVN 05 Dec '08
by FreeSWITCH SVN 05 Dec '08
05 Dec '08
Author: anthm
Date: Fri Dec 5 09:59:24 2008
New Revision: 10610
Log:
add vars param to switch_ivr_originate for recursion MODAPP_175
Modified:
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_ivr_originate.c
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Fri Dec 5 09:59:24 2008
@@ -398,7 +398,10 @@
const switch_state_handler_table_t *table,
const char *cid_name_override,
const char *cid_num_override,
- switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags);
+ switch_caller_profile_t *caller_profile_override,
+ switch_event_t *ovars,
+ switch_originate_flag_t flags
+ );
/*!
\brief Bridge Audio from one session to another
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Fri Dec 5 09:59:24 2008
@@ -1902,7 +1902,7 @@
timeout = atoi(argv[6]);
}
- if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS
+ if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS
|| !caller_session) {
if (machine) {
stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause));
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Fri Dec 5 09:59:24 2008
@@ -3807,7 +3807,7 @@
if (conference == NULL) {
char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto);
- status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, SOF_NONE);
+ status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE);
switch_safe_free(dialstr);
if (status != SWITCH_STATUS_SUCCESS) {
@@ -3840,7 +3840,7 @@
/* establish an outbound call leg */
- if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause));
if (caller_channel) {
switch_channel_hangup(caller_channel, *cause);
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Fri Dec 5 09:59:24 2008
@@ -1480,7 +1480,8 @@
timelimit = atoi(var);
}
- if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS || !peer_session) {
+ if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE)
+ != SWITCH_STATUS_SUCCESS || !peer_session) {
goto end;
}
@@ -1864,7 +1865,7 @@
}
}
- if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause));
/* no answer is *always* a reason to continue */
@@ -2097,7 +2098,7 @@
}
if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL,
- cid_name_override, cid_num_override, NULL, myflags) == SWITCH_STATUS_SUCCESS) {
+ cid_name_override, cid_num_override, NULL, var_event, myflags) == SWITCH_STATUS_SUCCESS) {
const char *context;
switch_caller_profile_t *cp;
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Fri Dec 5 09:59:24 2008
@@ -450,7 +450,7 @@
switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid);
fifo_execute_sql(sql, globals.sql_mutex);
- if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
(long)switch_timestamp(NULL), h->uuid);
fifo_execute_sql(sql, globals.sql_mutex);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Fri Dec 5 09:59:24 2008
@@ -3102,7 +3102,7 @@
private_object_t *tech_pvt = switch_core_session_get_private(session);
switch_channel_t *channel_a = switch_core_session_get_channel(session);
- status = switch_ivr_originate(a_session, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL, NULL, SOF_NONE);
+ status = switch_ivr_originate(a_session, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE);
if ((switch_channel_get_state(channel_a) < CS_HANGUP)) {
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Dec 5 09:59:24 2008
@@ -2781,7 +2781,7 @@
}
}
if (switch_ivr_originate(old_jss ? old_jss->session : NULL,
- &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) {
+ &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) {
switch_set_flag(jss, S_HUP);
switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE);
*rval = BOOLEAN_TO_JSVAL(JS_TRUE);
@@ -2921,7 +2921,7 @@
caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, modname, context, dest);
saveDepth = JS_SuspendRequest(cx);
- status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, SOF_NONE);
+ status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE);
JS_ResumeRequest(cx, saveDepth);
if (status != SWITCH_STATUS_SUCCESS) {
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Fri Dec 5 09:59:24 2008
@@ -467,7 +467,8 @@
allocated = 1;
} else {
switch_call_cause_t cause;
- if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) {
+ if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE)
+ == SWITCH_STATUS_SUCCESS) {
channel = switch_core_session_get_channel(session);
allocated = 1;
switch_set_flag(this, S_HUP);
@@ -919,6 +920,7 @@
NULL,
NULL,
&caller_profile,
+ NULL,
SOF_NONE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
goto failed;
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Fri Dec 5 09:59:24 2008
@@ -552,7 +552,10 @@
const switch_state_handler_table_t *table,
const char *cid_name_override,
const char *cid_num_override,
- switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags)
+ switch_caller_profile_t *caller_profile_override,
+ switch_event_t *ovars,
+ switch_originate_flag_t flags
+ )
{
switch_originate_flag_t dftflags = SOF_NONE, myflags = dftflags;
char *pipe_names[MAX_PEERS] = { 0 };
@@ -665,8 +668,13 @@
so we will normalize dialstring params and channel variables (when there is an originator) into an event that we
will use as a pseudo hash to consult for params as needed.
*/
- if (switch_event_create(&var_event, SWITCH_EVENT_GENERAL) != SWITCH_STATUS_SUCCESS) {
- abort();
+
+ if (ovars) {
+ var_event = ovars;
+ } else {
+ if (switch_event_create(&var_event, SWITCH_EVENT_GENERAL) != SWITCH_STATUS_SUCCESS) {
+ abort();
+ }
}
if (session) {
@@ -1684,7 +1692,7 @@
switch_ivr_sleep(session, 0, NULL);
}
- if (var_event) {
+ if (var_event && var_event != ovars) {
switch_event_destroy(&var_event);
}
switch_safe_free(write_frame.data);
1
0
[commit] r10609 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 05 Dec '08
by FreeSWITCH SVN 05 Dec '08
05 Dec '08
Author: gmaruzz
Date: Fri Dec 5 02:25:00 2008
New Revision: 10609
Log:
skypiax: cleaner
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Fri Dec 5 02:25:00 2008
@@ -58,7 +58,6 @@
#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-//#define SKYPIAX_P_LOG p ? p->owner : NULL, (unsigned long)pthread_self(), __LINE__, p ? p->name ? p->name : "none" : "none", p ? p->owner ? p->owner->_state : -1 : -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
/*********************************/
@@ -351,13 +350,9 @@
strncpy(msg_from_skype, (const char *) poCopyData->lpData,
sizeof(msg_from_skype) - 2);
- //howmany = strlen((const char *) poCopyData->lpData);
howmany = strlen(msg_from_skype) + 1;
- //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany);
switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany);
NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
- //howmany=1;
- //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany);
lReturnCode = 1;
}
break;
@@ -463,7 +458,6 @@
DWORD win32_dwThreadId;
-//void *do_skype_thread(void *data)
static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
{
/* create window class */
@@ -475,15 +469,6 @@
/* destroy main window */
/* destroy window class */
-#if 0
- res = pipe(p->AsteriskHandlesAst.fdesc);
- if (res) {
- ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
- }
-#endif //0
-
struct skypiax_interface *p;
p = obj;
@@ -560,110 +545,6 @@
}
-#undef PORTAUDIO_ENGAGE
-#ifdef PORTAUDIO_ENGAGE
-static switch_status_t engage_device(int sample_rate, int codec_ms)
-{
- PaStreamParameters inputParameters, outputParameters;
- PaError err;
-
- if (!globals.audio_stream) {
- if (!sample_rate) {
- sample_rate = globals.sample_rate;
- }
- if (!codec_ms) {
- codec_ms = globals.codec_ms;
- }
-
- if (!globals.read_codec.implementation) {
- if (switch_core_codec_init
- (&globals.read_codec, "L16", NULL, sample_rate, codec_ms, 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- return SWITCH_STATUS_FALSE;
- }
- }
-
- switch_assert(globals.read_codec.implementation);
-
- if (!globals.write_codec.implementation) {
- if (switch_core_codec_init
- (&globals.write_codec, "L16", NULL, sample_rate, codec_ms, 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- switch_core_codec_destroy(&globals.read_codec);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- if (!globals.timer.timer_interface) {
- if (switch_core_timer_init
- (&globals.timer, globals.timer_name, codec_ms,
- globals.read_codec.implementation->samples_per_packet,
- module_pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- if (!globals.hold_timer.timer_interface) {
- if (switch_core_timer_init
- (&globals.hold_timer, globals.timer_name, codec_ms,
- globals.read_codec.implementation->samples_per_packet,
- module_pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "setup hold timer failed!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- switch_core_timer_destroy(&globals.timer);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- globals.read_frame.rate = sample_rate;
- globals.read_frame.codec = &globals.read_codec;
-
- switch_mutex_lock(globals.device_lock);
- /* LOCKED ************************************************************************************************** */
- inputParameters.device = globals.indev;
- inputParameters.channelCount = 1;
- inputParameters.sampleFormat = SAMPLE_TYPE;
- inputParameters.suggestedLatency =
- Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
- inputParameters.hostApiSpecificStreamInfo = NULL;
-
- outputParameters.device = globals.outdev;
- outputParameters.channelCount = 1;
- outputParameters.sampleFormat = SAMPLE_TYPE;
- outputParameters.suggestedLatency =
- Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
- outputParameters.hostApiSpecificStreamInfo = NULL;
- err =
- OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters,
- sample_rate, paClipOff,
- globals.read_codec.implementation->samples_per_packet);
- /* UNLOCKED ************************************************************************************************* */
- switch_mutex_unlock(globals.device_lock);
-
- if (err != paNoError) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Can't open audio device!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- switch_core_timer_destroy(&globals.timer);
- switch_core_timer_destroy(&globals.hold_timer);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- return SWITCH_STATUS_SUCCESS;
-}
-#endif // PORTAUDIO_ENGAGE
-
#define SKYPE_AUDIO
#ifdef SKYPE_AUDIO
@@ -676,7 +557,6 @@
struct skypiax_interface *p = obj;
short in[GG];
short out[GG / 2];
- //int s, fd, len, sent;
int s, fd, len;
unsigned int sin_size;
struct sockaddr_in my_addr;
@@ -692,7 +572,6 @@
}
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
- //my_addr.sin_addr.s_addr = INADDR_ANY;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
my_addr.sin_port = htons(5556); //FIXME configurable!
@@ -769,8 +648,6 @@
howmany = len;
switch_file_write(p->audiopipe[1], totalbuf, &howmany);
- //howmany = len/2;
- //switch_file_write(p->audiopipe[1], out, &howmany);
p->audiobuf_is_loaded = 0;
//DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany);
}
@@ -797,7 +674,6 @@
switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
- //switch_sleep(1000000);
#ifndef WIN32_SKYPIAX
close(fd);
@@ -833,14 +709,12 @@
int a;
int i;
unsigned int got;
- //int exit=0;
if (option_debug > 10) {
WARNINGA("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 = INADDR_ANY;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
my_addr.sin_port = htons(5558); //FIXME configurable!
@@ -871,7 +745,6 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- //while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
while (p->interface_state != SKYPIAX_STATE_DOWN
&& (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|| p->skype_callflow == SKYPIAX_STATE_UP)) {
@@ -880,21 +753,16 @@
fd_set fs;
struct timeval to;
- //exit=1;
-
- //fdselect = p->audioskypepipe[0];
fdselect = 1;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
to.tv_usec = 100;
to.tv_sec = 0;
- //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
rt = 1;
if (rt > 0) {
got = (NN / 2) * sizeof(short);
switch_file_read(p->audioskypepipe[0], in, &got);
- //ERRORA("got %d\n", SKYPIAX_P_LOG, got);
if (got > 0) {
a = 0;
@@ -924,7 +792,6 @@
#else
closesocket(fd);
#endif
- //if (exit)
break;
}
@@ -943,63 +810,18 @@
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
-//switch_file_t *readp = NULL;
-//switch_file_t *writep = NULL;
-
switch_status_t rv;
- //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
- //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000);
- //rv = switch_file_pipe_create(&readp, &writep, module_pool);
-
- //FIXME int c;
-#if 0
-/* build the pipe that will be polled on by pbx */
- c = pipe(p->audiopipe);
- if (c) {
- ERRORA("Unable to create audio pipe\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
-#endif
/* the pipe is our audio fd for pbx to poll on */
p->skypiax_sound_capt_fd = p->audiopipe[0];
- /* let's start the serial monitoring thread too, so we can have serial signaling */
-
-/*
- 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 > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
-*/
-
rv =
switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2,
module_pool);
rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
- //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000);
-#ifdef NOTDEF_WIN32_SKYPIAX
- c = pipe(p->audioskypepipe);
- if (c) {
- ERRORA("Unable to create audioskypepipe\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
- fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
- fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
-#endif // WIN32_SKYPIAX
-
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1010,10 +832,7 @@
struct skypiax_interface *p;
short buf[640];
unsigned int samples;
- //int fd;
int rt;
- //fd_set fs;
- //struct timeval to;
p = tech_pvt->p;
@@ -1021,14 +840,6 @@
memset(buf, '\0', sizeof(buf));
-#if 0
- fd = p->audiopipe[0];
- FD_ZERO(&fs);
- FD_SET(fd, &fs);
- to.tv_usec = 100000;
- to.tv_sec = 0;
- rt = select(fd + 1, &fs, NULL, NULL, &to);
-#endif
rt = 1;
if (rt > 0) {
@@ -1041,7 +852,6 @@
if (samples)
DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
samples, SAMPLES_PER_FRAME * sizeof(short));
- //switch_sleep(1000);
//do nothing
} else {
tech_pvt->read_frame.datalen = samples;
@@ -1058,63 +868,10 @@
return SWITCH_STATUS_SUCCESS;
}
-#if 0
-//cicopet
-struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p)
-{
- static struct ast_frame f;
- static short __buf[SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2];
- short *buf;
- int samples;
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2));
-
- buf = __buf + SKYPIAX_FRIENDLY_OFFSET / 2;
-
- f.frametype = SKYPIAX_FRAME_NULL;
- f.subclass = 0;
- f.samples = 0;
- f.datalen = 0;
- f.data = NULL;
- f.offset = 0;
- f.src = skypiax_type;
- f.mallocd = 0;
- f.delivery.tv_sec = 0;
- f.delivery.tv_usec = 0;
-
- if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
- DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
- SAMPLES_PER_FRAME * sizeof(short));
- switch_sleep(100);
- //do nothing
- } else {
- //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- f.frametype = SKYPIAX_FRAME_VOICE;
- f.subclass = SKYPIAX_FORMAT_SLINEAR;
- f.samples = SKYPIAX_FRAME_SIZE;
- f.datalen = SKYPIAX_FRAME_SIZE * 2;
- f.data = buf;
- f.offset = SKYPIAX_FRIENDLY_OFFSET;
- f.src = skypiax_type;
- f.mallocd = 0;
- }
-
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return &f;
-}
-#endif //0
-
#endif /* SKYPE_AUDIO */
static void tech_init(private_t * tech_pvt, switch_core_session_t * session,
skypiax_interface_t * p)
{
- //struct skypiax_interface *p = NULL;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
tech_pvt->read_frame.data = tech_pvt->databuf;
@@ -1224,9 +981,6 @@
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
- //switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CHANNEL after TFLAG_HUP\n");
- //switch_thread_cond_signal(tech_pvt->cond);
break;
case SWITCH_SIG_BREAK:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
@@ -1268,8 +1022,6 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- //switch_time_t started = switch_time_now();
- //unsigned int elapsed;
switch_byte_t *data;
channel = switch_core_session_get_channel(session);
@@ -1304,26 +1056,6 @@
"CHANNEL READ FRAME not IO\n");
return SWITCH_STATUS_FALSE;
}
-#if 0
- if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
- DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
- SAMPLES_PER_FRAME * sizeof(short));
- switch_sleep(100);
- //do nothing
- } else {
- //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- f.frametype = SKYPIAX_FRAME_VOICE;
- f.subclass = SKYPIAX_FORMAT_SLINEAR;
- f.samples = SKYPIAX_FRAME_SIZE;
- f.datalen = SKYPIAX_FRAME_SIZE * 2;
- f.data = buf;
- f.offset = SKYPIAX_FRIENDLY_OFFSET;
- f.src = skypiax_type;
- f.mallocd = 0;
- }
-#endif
-
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n");
if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
@@ -1367,7 +1099,6 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- //switch_frame_t *pframe;
unsigned int sent;
struct skypiax_interface *p = NULL;
@@ -1400,225 +1131,6 @@
}
-#if 0
-switch_file_t *readp = NULL;
-switch_file_t *writep = NULL;
-
-void create_pipe(void *data)
-{
- switch_status_t rv;
-
- //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
- rv = switch_file_pipe_create_ex(&readp, &writep, 2, module_pool);
- //rv = switch_file_pipe_create(&readp, &writep, module_pool);
-}
-
-#if 0
-//testpipe.c
-
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-
-#include "testutil.h"
-#include "apr_file_io.h"
-#include "apr_errno.h"
-#include "apr_general.h"
-#include "apr_lib.h"
-#include "apr_thread_proc.h"
-#include "apr_strings.h"
-
-static apr_file_t *readp = NULL;
-static apr_file_t *writep = NULL;
-
-static void create_pipe(abts_case * tc, void *data)
-{
- apr_status_t rv;
-
- rv = apr_file_pipe_create(&readp, &writep, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
-}
-
-static void close_pipe(abts_case * tc, void *data)
-{
- apr_status_t rv;
- apr_size_t nbytes = 256;
- char buf[256];
-
- rv = apr_file_close(readp);
- rv = apr_file_close(writep);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_file_read(readp, buf, &nbytes);
- ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
-}
-
-static void set_timeout(abts_case * tc, void *data)
-{
- apr_status_t rv;
- apr_interval_time_t timeout;
-
- rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
-
- rv = apr_file_pipe_timeout_get(writep, &timeout);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1);
-
- rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_file_pipe_timeout_get(readp, &timeout);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second", timeout == apr_time_from_sec(1));
-}
-
-static void read_write(abts_case * tc, void *data)
-{
- apr_status_t rv;
- char *buf;
- apr_size_t nbytes;
-
- nbytes = strlen("this is a test");
- buf = (char *) apr_palloc(p, nbytes + 1);
-
- rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
-
- rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- if (!rv) {
- rv = apr_file_read(readp, buf, &nbytes);
- ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
- ABTS_SIZE_EQUAL(tc, 0, nbytes);
- }
-}
-
-static void read_write_notimeout(abts_case * tc, void *data)
-{
- apr_status_t rv;
- char *buf = "this is a test";
- char *input;
- apr_size_t nbytes;
-
- nbytes = strlen("this is a test");
-
- rv = apr_file_pipe_create(&readp, &writep, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
-
- rv = apr_file_write(writep, buf, &nbytes);
- ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- nbytes = 256;
- input = apr_pcalloc(p, nbytes + 1);
- rv = apr_file_read(readp, input, &nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
- ABTS_STR_EQUAL(tc, "this is a test", input);
-}
-
-static void test_pipe_writefull(abts_case * tc, void *data)
-{
- int iterations = 1000;
- int i;
- int bytes_per_iteration = 8000;
- char *buf = (char *) malloc(bytes_per_iteration);
- char responsebuf[128];
- apr_size_t nbytes;
- int bytes_processed;
- apr_proc_t proc = { 0 };
- apr_procattr_t *procattr;
- const char *args[2];
- apr_status_t rv;
- apr_exit_why_e why;
-
- rv = apr_procattr_create(&procattr, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK, APR_CHILD_BLOCK);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_procattr_error_check_set(procattr, 1);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- args[0] = "readchild" EXTENSION;
- args[1] = NULL;
- rv = apr_proc_create(&proc, TESTBINPATH "readchild" EXTENSION, args, NULL, procattr, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- i = iterations;
- do {
- rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- } while (--i);
-
- free(buf);
-
- rv = apr_file_close(proc.in);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- nbytes = sizeof(responsebuf);
- rv = apr_file_read(proc.out, responsebuf, &nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- bytes_processed = (int) apr_strtoi64(responsebuf, NULL, 10);
- ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
-
- ABTS_ASSERT(tc, "wait for child process",
- apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
-
- ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
-}
-
-abts_suite *testpipe(abts_suite * suite)
-{
- suite = ADD_SUITE(suite)
-
- abts_run_test(suite, create_pipe, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, set_timeout, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, read_write, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, read_write_notimeout, NULL);
- abts_run_test(suite, test_pipe_writefull, NULL);
- abts_run_test(suite, close_pipe, NULL);
-
- return suite;
-}
-
-#endif
-
-#endif
static switch_status_t channel_answer_channel(switch_core_session_t * session)
{
private_t *tech_pvt;
@@ -1671,64 +1183,6 @@
return SWITCH_STATUS_SUCCESS;
}
-#if 0
-/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
- that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
-*/
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
- switch_event_t * var_event,
- switch_caller_profile_t *
- outbound_profile,
- switch_core_session_t ** new_session,
- switch_memory_pool_t ** pool,
- switch_originate_flag_t flags)
-{
- if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
- private_t *tech_pvt;
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
-
- switch_core_session_add_stream(*new_session, NULL);
- if ((tech_pvt =
- (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = SKYPIAX_INTERFACES[2]; //FIXME
- channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session, NULL);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Hey where is my memory pool?\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
- if (outbound_profile) {
- char name[128];
-
- snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
- switch_channel_set_name(channel, name);
-
- caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
- switch_channel_set_caller_profile(channel, caller_profile);
- tech_pvt->caller_profile = caller_profile;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
- skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30);
-
- switch_channel_set_flag(channel, CF_OUTBOUND);
- switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
- switch_channel_set_state(channel, CS_INIT);
- return SWITCH_CAUSE_SUCCESS;
- }
-
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
-
-}
-#endif // 0 //FIXME: moved below
-
static switch_status_t channel_receive_event(switch_core_session_t * session,
switch_event_t * event)
{
@@ -1908,35 +1362,13 @@
Display *disp = NULL;
Window root = -1;
Window win = -1;
-//int res;
p = obj;
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;
- }
-*/
-
switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
&p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
-#if 0
- res = pipe(p->AsteriskHandlesAst.fdesc);
- if (res) {
- ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
- }
- fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
- fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
-#endif
-
AsteriskHandlesAst = &p->AsteriskHandlesAst;
//disp = XOpenDisplay(getenv("DISPLAY"));
disp = XOpenDisplay(p->X11_display);
@@ -1978,8 +1410,6 @@
ERRORA
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
- //p->skype = 0;
- //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1989,8 +1419,6 @@
ERRORA
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
- //p->skype = 0;
- //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -2005,7 +1433,6 @@
b = buffer;
while (1) {
- //pthread_testcancel();
XNextEvent(disp, &an_event);
switch (an_event.type) {
case ClientMessage:
@@ -2045,13 +1472,8 @@
ERRORA
("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
SKYPIAX_P_LOG);
- //p->skype = 0;
- //p->skype_thread = SKYPIAX_PTHREADT_NULL;
return NULL;
}
- //p->skype = 0;
- //p->skype_thread = SKYPIAX_PTHREADT_NULL;
- //pthread_cleanup_pop(1);
//DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
@@ -2117,8 +1539,6 @@
ERRORA
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
- //p->skype = 0;
- //p->skype_thread = SKYPIAX_PTHREADT_NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -2153,21 +1573,11 @@
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
- //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-//switch_sleep(1000000);
memset(read_from_pipe, 0, 4096);
memset(messaggio, 0, 4096);
memset(messaggio_2, 0, 4096);
-#if 0
- fd = p->AsteriskHandlesAst.fdesc[0];
- FD_ZERO(&fs);
- FD_SET(fd, &fs);
- to.tv_usec = 100;
- to.tv_sec = 0;
- rt = select(fd + 1, &fs, NULL, NULL, &to);
-#endif
rt = 1;
if (rt > 0) {
howmany = sizeof(read_from_pipe);
@@ -2184,18 +1594,6 @@
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
-#if 0 //FIXME wat's the use of this?
- if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
- just authorized */
- NOTICA
- ("Please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
- SKYPIAX_P_LOG);
- sleep(1);
- skypiax_skype_write(p, "PROTOCOL 6");
- switch_sleep(10000);
- }
-#endif
-
if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
SKYPIAX_P_LOG, messaggio);
@@ -2209,8 +1607,6 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2256,9 +1652,6 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner){
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
- //FIXME }
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2318,7 +1711,6 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- //FIXME struct ast_frame f2 = { SKYPIAX_FRAME_DTMF, value[0], };
DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
tech_pvt = p->tech_pvt;
@@ -2337,11 +1729,9 @@
switch_set_flag(tech_pvt, TFLAG_DTMF);
switch_mutex_unlock(tech_pvt->flag_mutex);
}
- //FIXME ast_queue_frame(p->owner, &f2);
}
if (!strcasecmp(prop, "FAILUREREASON")) {
- /* if (option_debug > 1) */
DEBUGA_SKYPE
("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
SKYPIAX_P_LOG, id);
@@ -2363,7 +1753,6 @@
if (p->interface_state != SKYPIAX_STATE_DIALING) {
/* we are not calling out */
- //FIXME if (!p->owner)
if (1) {
/* we are not inside an active call */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
@@ -2425,8 +1814,6 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2445,8 +1832,6 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2463,8 +1848,6 @@
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
if (!strcasecmp(id, p->skype_call_id)) {
@@ -2480,8 +1863,6 @@
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
/* we're here because were us that refused an incoming call */
@@ -2505,57 +1886,30 @@
if (option_debug > 1)
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
- //FIXME if (p->owner) {
- //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER);
- //FIXME }
if (option_debug > 1)
DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
SKYPIAX_P_LOG, id);
- //FIXME if (p->owner)
-
if (1) {
char msg_to_skype[1024];
-#if 0
- if (!p->tcp_srv_thread) {
- if (1) {
-#endif
- //switch_thread_t *thread;
- if (1) {
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_srv_thread, thd_attr,
- skypiax_do_tcp_srv_thread, p, module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-#if 0
- }
- }
-#endif
-
-#if 0
- if (!p->tcp_cli_thread) {
- if (1) {
-#endif
- //switch_thread_t *thread;
- //switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_cli_thread, thd_attr,
- skypiax_do_tcp_cli_thread, p, module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
-#if 0
- }
+ if (1) {
+ switch_threadattr_t *thd_attr = NULL;
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_srv_thread, thd_attr,
+ skypiax_do_tcp_srv_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_cli_thread, thd_attr,
+ skypiax_do_tcp_cli_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
}
-#endif
-
switch_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
skypiax_skype_write(p, msg_to_skype);
@@ -2618,27 +1972,6 @@
"Error spawning thread\n");
switch_core_session_destroy(&session);
}
-#if 0
- if (iax_set_codec
- (tech_pvt, iaxevent->session, &iaxevent->ies.format,
- &iaxevent->ies.capability, &iaxevent->ies.samprate,
- IAX_SET) != SWITCH_STATUS_SUCCESS) {
- iax_reject(iaxevent->session, "Codec Error!");
- switch_core_session_destroy(&session);
- } else {
- tech_pvt->iax_session = iaxevent->session;
- tech_pvt->session = session;
- iax_accept(tech_pvt->iax_session, tech_pvt->codec);
- iax_ring_announce(tech_pvt->iax_session);
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) !=
- SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Error spawning thread\n");
- switch_core_session_destroy(&session);
- }
- }
-#endif //0
}
} else {
switch_core_session_t *session = NULL;
@@ -2693,18 +2026,10 @@
strncpy(rdest, "echo123", sizeof(rdest) - 1);
if (option_debug)
DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
- //skypiax_skype_write(p, "GET AGC");
- //switch_sleep(10000);
skypiax_skype_write(p, "SET AGC OFF");
switch_sleep(10000);
- //skypiax_skype_write(p, "GET AGC");
- //switch_sleep(10000);
- //skypiax_skype_write(p, "GET AEC");
- //switch_sleep(10000);
skypiax_skype_write(p, "SET AEC OFF");
switch_sleep(10000);
- //skypiax_skype_write(p, "GET AEC");
- //switch_sleep(300000);
sprintf(msg_to_skype, "CALL %s", rdest);
if (skypiax_skype_write(p, msg_to_skype) < 0) {
@@ -2716,11 +2041,7 @@
return -1;
}
global_session = session;
- //p->skype_call_ongoing = 1;
- //if (p->owner) {
- //ast_setstate(p->owner, SKYPIAX_STATE_RINGING);
- //}
//FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
return 0;
}
@@ -2785,7 +2106,6 @@
*/
static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t * thread,
void *obj)
-//void *skypiax_do_controldev_thread(void *data)
{
struct skypiax_interface *p = obj;
int res;
@@ -2805,8 +2125,6 @@
private_t *tech_pvt;
switch_channel_t *channel;
- //p->interface_state=SKYPIAX_STATE_DOWN;
- //if (option_debug)
DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
tech_pvt = p->tech_pvt;
@@ -2815,8 +2133,6 @@
channel = switch_core_session_get_channel(session);
DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
- //switch_channel_set_state(channel, CS_HANGUP);
-
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
1
0
[commit] r10608 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 05 Dec '08
by FreeSWITCH SVN 05 Dec '08
05 Dec '08
Author: gmaruzz
Date: Fri Dec 5 02:06:43 2008
New Revision: 10608
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/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Fri Dec 5 02:06:43 2008
@@ -58,11 +58,9 @@
#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-
//#define SKYPIAX_P_LOG p ? p->owner : NULL, (unsigned long)pthread_self(), __LINE__, p ? p->name ? p->name : "none" : "none", p ? p->owner ? p->owner->_state : -1 : -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
-
/*********************************/
#define SKYPIAX_CAUSE_NORMAL 1
/*********************************/
@@ -111,15 +109,12 @@
/*********************************/
-
-
#define SKYPIAX_MAX_INTERFACES 64
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
//SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime);
-SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime);
-
+SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime);
switch_endpoint_interface_t *skypiax_endpoint_interface;
static switch_memory_pool_t *module_pool = NULL;
@@ -142,135 +137,136 @@
#endif //WIN32_SKYPIAX
-
typedef enum {
- TFLAG_IO = (1 << 0),
- TFLAG_INBOUND = (1 << 1),
- TFLAG_OUTBOUND = (1 << 2),
- TFLAG_DTMF = (1 << 3),
- TFLAG_VOICE = (1 << 4),
- TFLAG_HANGUP = (1 << 5),
- TFLAG_LINEAR = (1 << 6),
- TFLAG_CODEC = (1 << 7),
- TFLAG_BREAK = (1 << 8)
+ TFLAG_IO = (1 << 0),
+ TFLAG_INBOUND = (1 << 1),
+ TFLAG_OUTBOUND = (1 << 2),
+ TFLAG_DTMF = (1 << 3),
+ TFLAG_VOICE = (1 << 4),
+ TFLAG_HANGUP = (1 << 5),
+ TFLAG_LINEAR = (1 << 6),
+ TFLAG_CODEC = (1 << 7),
+ TFLAG_BREAK = (1 << 8)
} TFLAGS;
typedef enum {
- GFLAG_MY_CODEC_PREFS = (1 << 0)
+ GFLAG_MY_CODEC_PREFS = (1 << 0)
} GFLAGS;
-
static struct {
- int debug;
- char *ip;
- int port;
- char *dialplan;
- char *codec_string;
- char *codec_order[SWITCH_MAX_CODECS];
- int codec_order_last;
- char *codec_rates_string;
- char *codec_rates[SWITCH_MAX_CODECS];
- int codec_rates_last;
- unsigned int flags;
- int fd;
- int calls;
- char hold_music[256];
- switch_mutex_t *mutex;
+ int debug;
+ char *ip;
+ int port;
+ char *dialplan;
+ char *codec_string;
+ char *codec_order[SWITCH_MAX_CODECS];
+ int codec_order_last;
+ char *codec_rates_string;
+ char *codec_rates[SWITCH_MAX_CODECS];
+ int codec_rates_last;
+ unsigned int flags;
+ int fd;
+ int calls;
+ char hold_music[256];
+ switch_mutex_t *mutex;
} globals;
struct skypiax_interface {
- char interface_id[80];
- char name[80];
- char dialplan[80];
- char context[80];
- char dial_regex[256];
- char fail_dial_regex[256];
- char hold_music[256];
- char type[256];
- char X11_display[256];
- struct AsteriskHandles AsteriskHandlesAst;
-
- int interface_state; /*!< \brief 'state' of the interface (channel) */
- 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;
- double capture_boost;
- int stripmsd;
- switch_thread_t *skype_thread;
- char skype_call_id[512];
- int skype_call_ongoing;
- char skype_friends[4096];
- char skype_fullname[512];
- char skype_displayname[512];
- int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
- int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
- int control_to_send;
- switch_file_t *audiopipe[2];
- switch_file_t *audioskypepipe[2];
- switch_thread_t *tcp_srv_thread;
- switch_thread_t *tcp_cli_thread;
- short audiobuf[160];
- int audiobuf_is_loaded;
-
- //int phonebook_listing;
- //int phonebook_querying;
- //int phonebook_listing_received_calls;
-
- //int phonebook_first_entry;
- //int phonebook_last_entry;
- //int phonebook_number_lenght;
- //int phonebook_text_lenght;
- FILE *phonebook_writing_fp;
- int skypiax_dir_entry_extension_prefix;
- void *tech_pvt;
+ char interface_id[80];
+ char name[80];
+ char dialplan[80];
+ char context[80];
+ char dial_regex[256];
+ char fail_dial_regex[256];
+ char hold_music[256];
+ char type[256];
+ char X11_display[256];
+ struct AsteriskHandles AsteriskHandlesAst;
+
+ int interface_state; /*!< \brief 'state' of the interface (channel) */
+ 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;
+ double capture_boost;
+ int stripmsd;
+ switch_thread_t *skype_thread;
+ char skype_call_id[512];
+ int skype_call_ongoing;
+ char skype_friends[4096];
+ char skype_fullname[512];
+ char skype_displayname[512];
+ int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
+ int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
+ int control_to_send;
+ switch_file_t *audiopipe[2];
+ switch_file_t *audioskypepipe[2];
+ switch_thread_t *tcp_srv_thread;
+ switch_thread_t *tcp_cli_thread;
+ short audiobuf[160];
+ int audiobuf_is_loaded;
+
+ //int phonebook_listing;
+ //int phonebook_querying;
+ //int phonebook_listing_received_calls;
+
+ //int phonebook_first_entry;
+ //int phonebook_last_entry;
+ //int phonebook_number_lenght;
+ //int phonebook_text_lenght;
+ FILE *phonebook_writing_fp;
+ int skypiax_dir_entry_extension_prefix;
+ void *tech_pvt;
};
typedef struct skypiax_interface skypiax_interface_t;
static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
-
struct private_object {
- unsigned int flags;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
- switch_frame_t read_frame;
- unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
- switch_core_session_t *session;
- switch_caller_profile_t *caller_profile;
- switch_mutex_t *mutex;
- switch_mutex_t *flag_mutex;
- skypiax_interface_t *p;
- //switch_thread_cond_t *cond;
+ unsigned int flags;
+ switch_codec_t read_codec;
+ switch_codec_t write_codec;
+ switch_frame_t read_frame;
+ unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_core_session_t *session;
+ switch_caller_profile_t *caller_profile;
+ switch_mutex_t *mutex;
+ switch_mutex_t *flag_mutex;
+ skypiax_interface_t *p;
+ //switch_thread_cond_t *cond;
};
typedef struct private_object private_t;
-
-
-
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
-SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string);
+SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string,
+ globals.codec_rates_string);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip);
-
-
-static switch_status_t channel_on_init(switch_core_session_t *session);
-static switch_status_t channel_on_hangup(switch_core_session_t *session);
-static switch_status_t channel_on_routing(switch_core_session_t *session);
-static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
-static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
- switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags);
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
-static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
+static switch_status_t channel_on_init(switch_core_session_t * session);
+static switch_status_t channel_on_hangup(switch_core_session_t * session);
+static switch_status_t channel_on_routing(switch_core_session_t * session);
+static switch_status_t channel_on_exchange_media(switch_core_session_t * session);
+static switch_status_t channel_on_soft_execute(switch_core_session_t * session);
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
+ switch_event_t * var_event,
+ switch_caller_profile_t *
+ outbound_profile,
+ switch_core_session_t ** new_session,
+ switch_memory_pool_t ** pool,
+ switch_originate_flag_t flags);
+static switch_status_t channel_read_frame(switch_core_session_t * session,
+ switch_frame_t ** frame, switch_io_flag_t flags,
+ int stream_id);
+static switch_status_t channel_write_frame(switch_core_session_t * session,
+ switch_frame_t * frame, switch_io_flag_t flags,
+ int stream_id);
+static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig);
int option_debug = 100;
switch_core_session_t *global_session = NULL;
@@ -310,17 +306,16 @@
SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
};
-
char
-*strsep(char **stringp, const char *delim)
+ *strsep(char **stringp, const char *delim)
{
char *res;
if (!stringp || !*stringp || !**stringp)
- return (char*)0;
+ return (char *) 0;
res = *stringp;
- while(**stringp && !strchr(delim, **stringp))
+ while (**stringp && !strchr(delim, **stringp))
++(*stringp);
if (**stringp) {
@@ -331,8 +326,6 @@
return res;
}
-
-
LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
LPARAM ulParam)
{
@@ -349,20 +342,20 @@
break;
case WM_COPYDATA:
if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
- unsigned int howmany;
- char msg_from_skype[2048];
-
+ unsigned int howmany;
+ char msg_from_skype[2048];
PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
- memset(msg_from_skype, '\0', sizeof(msg_from_skype));
- strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) -2);
+ memset(msg_from_skype, '\0', sizeof(msg_from_skype));
+ strncpy(msg_from_skype, (const char *) poCopyData->lpData,
+ sizeof(msg_from_skype) - 2);
//howmany = strlen((const char *) poCopyData->lpData);
howmany = strlen(msg_from_skype) + 1;
//switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany);
switch_file_write(win32_AsteriskHandlesSkype->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, (const char *) poCopyData->lpData);
//howmany=1;
//switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany);
lReturnCode = 1;
@@ -471,7 +464,7 @@
DWORD win32_dwThreadId;
//void *do_skype_thread(void *data)
-static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
+static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
{
/* create window class */
/* create dummy/hidden window for processing messages */
@@ -487,14 +480,15 @@
if (res) {
ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
+ return NULL;
}
#endif //0
struct skypiax_interface *p;
p = obj;
- switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
+ &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst;
@@ -535,146 +529,149 @@
#endif /* __CYGWIN__ */
-
-
#endif //WIN32_SKYPIAX
-
-static switch_status_t skypiax_codec(private_t *tech_pvt, int sample_rate, int codec_ms)
+static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
{
- if (switch_core_codec_init(&tech_pvt->read_codec,
- "L16",
- NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- return SWITCH_STATUS_FALSE;
- }
-
- if (switch_core_codec_init(&tech_pvt->write_codec,
- "L16",
- NULL,
- sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- switch_core_codec_destroy(&tech_pvt->read_codec);
- return SWITCH_STATUS_FALSE;
- }
-
- tech_pvt->read_frame.rate = sample_rate;
- tech_pvt->read_frame.codec = &tech_pvt->read_codec;
+ if (switch_core_codec_init
+ (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (switch_core_codec_init
+ (&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ return SWITCH_STATUS_FALSE;
+ }
+ tech_pvt->read_frame.rate = sample_rate;
+ tech_pvt->read_frame.codec = &tech_pvt->read_codec;
- switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
- switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
+ switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
+ switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
+
#undef PORTAUDIO_ENGAGE
#ifdef PORTAUDIO_ENGAGE
static switch_status_t engage_device(int sample_rate, int codec_ms)
{
- PaStreamParameters inputParameters, outputParameters;
- PaError err;
+ PaStreamParameters inputParameters, outputParameters;
+ PaError err;
+
+ if (!globals.audio_stream) {
+ if (!sample_rate) {
+ sample_rate = globals.sample_rate;
+ }
+ if (!codec_ms) {
+ codec_ms = globals.codec_ms;
+ }
+
+ if (!globals.read_codec.implementation) {
+ if (switch_core_codec_init
+ (&globals.read_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+ switch_assert(globals.read_codec.implementation);
+
+ if (!globals.write_codec.implementation) {
+ if (switch_core_codec_init
+ (&globals.write_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ switch_core_codec_destroy(&globals.read_codec);
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+ if (!globals.timer.timer_interface) {
+ if (switch_core_timer_init
+ (&globals.timer, globals.timer_name, codec_ms,
+ globals.read_codec.implementation->samples_per_packet,
+ module_pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
+ switch_core_codec_destroy(&globals.read_codec);
+ switch_core_codec_destroy(&globals.write_codec);
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+ if (!globals.hold_timer.timer_interface) {
+ if (switch_core_timer_init
+ (&globals.hold_timer, globals.timer_name, codec_ms,
+ globals.read_codec.implementation->samples_per_packet,
+ module_pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "setup hold timer failed!\n");
+ switch_core_codec_destroy(&globals.read_codec);
+ switch_core_codec_destroy(&globals.write_codec);
+ switch_core_timer_destroy(&globals.timer);
+ return SWITCH_STATUS_FALSE;
+ }
+ }
+
+ globals.read_frame.rate = sample_rate;
+ globals.read_frame.codec = &globals.read_codec;
- if (!globals.audio_stream) {
- if (!sample_rate) {
- sample_rate = globals.sample_rate;
- }
- if (!codec_ms) {
- codec_ms = globals.codec_ms;
- }
-
- if (!globals.read_codec.implementation) {
- if (switch_core_codec_init(&globals.read_codec,
- "L16",
- NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- return SWITCH_STATUS_FALSE;
- }
- }
-
- switch_assert(globals.read_codec.implementation);
-
- if (!globals.write_codec.implementation) {
- if (switch_core_codec_init(&globals.write_codec,
- "L16",
- NULL,
- sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
- switch_core_codec_destroy(&globals.read_codec);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- if (!globals.timer.timer_interface) {
- if (switch_core_timer_init(&globals.timer,
- globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
- module_pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- if (!globals.hold_timer.timer_interface) {
- if (switch_core_timer_init(&globals.hold_timer,
- globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
- module_pool) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- switch_core_timer_destroy(&globals.timer);
- return SWITCH_STATUS_FALSE;
- }
- }
-
- globals.read_frame.rate = sample_rate;
- globals.read_frame.codec = &globals.read_codec;
-
- switch_mutex_lock(globals.device_lock);
- /* LOCKED ************************************************************************************************** */
- inputParameters.device = globals.indev;
- inputParameters.channelCount = 1;
- inputParameters.sampleFormat = SAMPLE_TYPE;
- inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
- inputParameters.hostApiSpecificStreamInfo = NULL;
-
- outputParameters.device = globals.outdev;
- outputParameters.channelCount = 1;
- outputParameters.sampleFormat = SAMPLE_TYPE;
- outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
- outputParameters.hostApiSpecificStreamInfo = NULL;
- err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
- globals.read_codec.implementation->samples_per_packet);
- /* UNLOCKED ************************************************************************************************* */
- switch_mutex_unlock(globals.device_lock);
-
- if (err != paNoError) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n");
- switch_core_codec_destroy(&globals.read_codec);
- switch_core_codec_destroy(&globals.write_codec);
- switch_core_timer_destroy(&globals.timer);
- switch_core_timer_destroy(&globals.hold_timer);
- return SWITCH_STATUS_FALSE;
- }
- }
+ switch_mutex_lock(globals.device_lock);
+ /* LOCKED ************************************************************************************************** */
+ inputParameters.device = globals.indev;
+ inputParameters.channelCount = 1;
+ inputParameters.sampleFormat = SAMPLE_TYPE;
+ inputParameters.suggestedLatency =
+ Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency;
+ inputParameters.hostApiSpecificStreamInfo = NULL;
+
+ outputParameters.device = globals.outdev;
+ outputParameters.channelCount = 1;
+ outputParameters.sampleFormat = SAMPLE_TYPE;
+ outputParameters.suggestedLatency =
+ Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
+ outputParameters.hostApiSpecificStreamInfo = NULL;
+ err =
+ OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters,
+ sample_rate, paClipOff,
+ globals.read_codec.implementation->samples_per_packet);
+ /* UNLOCKED ************************************************************************************************* */
+ switch_mutex_unlock(globals.device_lock);
+
+ if (err != paNoError) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Can't open audio device!\n");
+ switch_core_codec_destroy(&globals.read_codec);
+ switch_core_codec_destroy(&globals.write_codec);
+ switch_core_timer_destroy(&globals.timer);
+ switch_core_timer_destroy(&globals.hold_timer);
+ return SWITCH_STATUS_FALSE;
+ }
+ }
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
#endif // PORTAUDIO_ENGAGE
-
#define SKYPE_AUDIO
#ifdef SKYPE_AUDIO
#define SAMPLES_PER_FRAME 160
#define NN 160
#define GG 160
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
+static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
+ void *obj)
{
struct skypiax_interface *p = obj;
short in[GG];
@@ -696,8 +693,8 @@
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
//my_addr.sin_addr.s_addr = INADDR_ANY;
- my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(5556); //FIXME configurable!
+ my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
+ my_addr.sin_port = htons(5556); //FIXME configurable!
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -721,87 +718,82 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS ||p->skype_callflow == SKYPIAX_STATE_UP)) {
-
- int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- exit=1;
-
-
-
-
-
-
- fdselect = fd;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 100;
- to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- if (rt > 0) {
-
- len = recv(fd, in, sizeof(short) * GG, 0);
- //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
- if (len > 0) {
- a = 0;
- for (i = 0; i < len / sizeof(short); i++) {
- out[a] = in[i];
- i++;
- a++;
- }
-
- if (!p->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)) / 2; i++) {
- p->audiobuf[i] = out[i];
+ while (p->interface_state != SKYPIAX_STATE_DOWN
+ && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || p->skype_callflow == SKYPIAX_STATE_UP)) {
+
+ int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+
+ exit = 1;
+
+ fdselect = fd;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 100;
+ to.tv_sec = 0;
+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
+
+ len = recv(fd, in, sizeof(short) * GG, 0);
+ //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
+ if (len > 0) {
+ a = 0;
+ for (i = 0; i < len / sizeof(short); i++) {
+ out[a] = in[i];
+ i++;
+ a++;
}
- p->audiobuf_is_loaded = 1;
- } else {
- unsigned int howmany;
+
+ if (!p->audiobuf_is_loaded) {
+ for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+ p->audiobuf[i] = out[i];
+ }
+ p->audiobuf_is_loaded = 1;
+ } else {
+ unsigned int howmany;
short totalbuf[GG];
- howmany = len/2/2;
- for(i=0; i<howmany; i++)
- totalbuf[i] = p->audiobuf[i];
-
- howmany = len/2/2;
- for(a=0; a<howmany; a++){
- totalbuf[i] = out[a];
- i++;
+ howmany = len / 2 / 2;
+ for (i = 0; i < howmany; i++)
+ totalbuf[i] = p->audiobuf[i];
+
+ howmany = len / 2 / 2;
+ for (a = 0; a < howmany; a++) {
+ totalbuf[i] = out[a];
+ i++;
}
howmany = len;
- switch_file_write(p->audiopipe[1], totalbuf, &howmany);
- //howmany = len/2;
- //switch_file_write(p->audiopipe[1], out, &howmany);
- p->audiobuf_is_loaded = 0;
- //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany);
- }
+ switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+ //howmany = len/2;
+ //switch_file_write(p->audiopipe[1], out, &howmany);
+ p->audiobuf_is_loaded = 0;
+ //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany);
+ }
- } else if (len == 0) {
- DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
- break;
- } else {
- ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
- exit = 1;
- break;
+ } else if (len == 0) {
+ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+ break;
+ } else {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ exit = 1;
+ break;
+ }
}
- }
}
-
-
- kill_cli_size=320;
+ kill_cli_size = 320;
switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size=320;
+ kill_cli_size = 320;
switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
p->interface_state = SKYPIAX_STATE_DOWN;
- kill_cli_size=320;
+ kill_cli_size = 320;
switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size=320;
+ kill_cli_size = 320;
switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
@@ -827,7 +819,8 @@
}
return NULL;
}
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
+static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
+ void *obj)
//void *skypiax_do_tcp_cli_thread(void *data)
{
struct skypiax_interface *p = obj;
@@ -848,8 +841,8 @@
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
//my_addr.sin_addr.s_addr = INADDR_ANY;
- my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(5558); //FIXME configurable!
+ my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
+ my_addr.sin_port = htons(5558); //FIXME configurable!
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -865,9 +858,9 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
#ifndef WIN32_SKYPIAX
- close(s);
+ close(s);
#else
- closesocket(s);
+ closesocket(s);
#endif
return NULL;
}
@@ -879,54 +872,50 @@
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
//while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
- while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS ||p->skype_callflow == SKYPIAX_STATE_UP)) {
- int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- //exit=1;
-
-
-
-
-
-
- //fdselect = p->audioskypepipe[0];
- fdselect=1;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 100;
- to.tv_sec = 0;
- //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- rt=1;
- if (rt > 0) {
-
-
- got = (NN / 2) * sizeof(short);
- switch_file_read(p->audioskypepipe[0], in, &got);
- //ERRORA("got %d\n", SKYPIAX_P_LOG, got);
-
- if (got > 0) {
- a = 0;
- for (i = 0; i < got / sizeof(short); i++) {
- out[a] = in[i];
- a++;
- out[a] = in[i];
- a++;
- }
+ while (p->interface_state != SKYPIAX_STATE_DOWN
+ && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || p->skype_callflow == SKYPIAX_STATE_UP)) {
+ int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+
+ //exit=1;
+
+ //fdselect = p->audioskypepipe[0];
+ fdselect = 1;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 100;
+ to.tv_sec = 0;
+ //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ rt = 1;
+ if (rt > 0) {
+
+ got = (NN / 2) * sizeof(short);
+ switch_file_read(p->audioskypepipe[0], in, &got);
+ //ERRORA("got %d\n", SKYPIAX_P_LOG, got);
+
+ if (got > 0) {
+ a = 0;
+ for (i = 0; i < got / sizeof(short); i++) {
+ out[a] = in[i];
+ a++;
+ out[a] = in[i];
+ a++;
+ }
- len = send(fd, out, got * 2, 0);
+ len = send(fd, out, got * 2, 0);
- if (len == 0) {
- ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
- break;
+ if (len == 0) {
+ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+ break;
+ }
+ } else {
+ switch_sleep(1000);
+ //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
}
- } else {
- switch_sleep(1000);
- //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
}
- }
}
ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
@@ -936,7 +925,7 @@
closesocket(fd);
#endif
//if (exit)
- break;
+ break;
}
WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG);
@@ -951,21 +940,19 @@
return NULL;
}
-
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
//switch_file_t *readp = NULL;
//switch_file_t *writep = NULL;
- switch_status_t rv;
-
- //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
- rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
- rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
- //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000);
- //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+ switch_status_t rv;
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
+ rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
+ //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
//FIXME int c;
#if 0
@@ -995,9 +982,11 @@
}
*/
- rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool);
- rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
- //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000);
+ rv =
+ switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2,
+ module_pool);
+ rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
+ //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000);
#ifdef NOTDEF_WIN32_SKYPIAX
c = pipe(p->audioskypepipe);
if (c) {
@@ -1009,16 +998,16 @@
}
fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
-#endif// WIN32_SKYPIAX
+#endif // WIN32_SKYPIAX
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return 0;
}
-static switch_status_t skypiax_skypeaudio_read(private_t *tech_pvt)
+static switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
{
- struct skypiax_interface *p;
+ struct skypiax_interface *p;
short buf[640];
unsigned int samples;
//int fd;
@@ -1026,10 +1015,9 @@
//fd_set fs;
//struct timeval to;
- p = tech_pvt->p;
-
- //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ p = tech_pvt->p;
+ //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
memset(buf, '\0', sizeof(buf));
@@ -1041,32 +1029,31 @@
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
#endif
- rt=1;
+ rt = 1;
if (rt > 0) {
+ samples = SAMPLES_PER_FRAME * sizeof(short);
- samples = SAMPLES_PER_FRAME * sizeof(short);
-
- switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
+ switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
- //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
- if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
- if(samples)
- DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short));
- //switch_sleep(1000);
- //do nothing
- } else {
- tech_pvt->read_frame.datalen=samples;
- //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- }
+ //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
+ if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samples)
+ DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
+ samples, SAMPLES_PER_FRAME * sizeof(short));
+ //switch_sleep(1000);
+ //do nothing
+ } else {
+ tech_pvt->read_frame.datalen = samples;
+ //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
+ /* A real frame */
+ }
} else {
DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
-
}
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -1124,280 +1111,292 @@
#endif //0
#endif /* SKYPE_AUDIO */
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p)
+static void tech_init(private_t * tech_pvt, switch_core_session_t * session,
+ skypiax_interface_t * p)
{
- //struct skypiax_interface *p = NULL;
+ //struct skypiax_interface *p = NULL;
- 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, switch_core_session_get_pool(session));
- switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
- switch_core_session_set_private(session, tech_pvt);
- tech_pvt->session = session;
- if(p){
- tech_pvt->p=p;
- p->tech_pvt=tech_pvt;
-
- }
-if ( skypiax_codec(tech_pvt, 8000, 20) != SWITCH_STATUS_SUCCESS)
-{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n");
-} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n");
-}
+ 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,
+ switch_core_session_get_pool(session));
+ switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED,
+ switch_core_session_get_pool(session));
+ switch_core_session_set_private(session, tech_pvt);
+ tech_pvt->session = session;
+ if (p) {
+ tech_pvt->p = p;
+ p->tech_pvt = tech_pvt;
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ if (skypiax_codec(tech_pvt, 8000, 20) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n");
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n");
+ }
+
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
+
/*
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it.
*/
-static switch_status_t channel_on_init(switch_core_session_t *session)
+static switch_status_t channel_on_init(switch_core_session_t * session)
{
- switch_channel_t *channel;
- private_t *tech_pvt = NULL;
-
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ switch_channel_t *channel;
+ private_t *tech_pvt = NULL;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- switch_set_flag_locked(tech_pvt, TFLAG_IO);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- /* Move channel's state machine to ROUTING. This means the call is trying
- to get from the initial start where the call because, to the point
- where a destination has been identified. If the channel is simply
- left in the initial state, nothing will happen. */
- switch_channel_set_state(channel, CS_ROUTING);
- switch_mutex_lock(globals.mutex);
- globals.calls++;
- switch_mutex_unlock(globals.mutex);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+ switch_set_flag_locked(tech_pvt, TFLAG_IO);
+
+ /* Move channel's state machine to ROUTING. This means the call is trying
+ to get from the initial start where the call because, to the point
+ where a destination has been identified. If the channel is simply
+ left in the initial state, nothing will happen. */
+ switch_channel_set_state(channel, CS_ROUTING);
+ switch_mutex_lock(globals.mutex);
+ globals.calls++;
+ switch_mutex_unlock(globals.mutex);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT\n", switch_channel_get_name(channel));
- return SWITCH_STATUS_SUCCESS;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT\n",
+ switch_channel_get_name(channel));
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_routing(switch_core_session_t *session)
+static switch_status_t channel_on_routing(switch_core_session_t * session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n",
+ switch_channel_get_name(channel));
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_execute(switch_core_session_t *session)
+static switch_status_t channel_on_execute(switch_core_session_t * session)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n",
+ switch_channel_get_name(channel));
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig)
+static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig)
{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- switch (sig) {
- case SWITCH_SIG_KILL:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL got SWITCH_SIG_KILL\n", switch_channel_get_name(channel));
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
- //switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CHANNEL after TFLAG_HUP\n");
- //switch_thread_cond_signal(tech_pvt->cond);
- break;
- case SWITCH_SIG_BREAK:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL got SWITCH_SIG_BREAK\n", switch_channel_get_name(channel));
- switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
- break;
- default:
- break;
- }
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
+
+ switch (sig) {
+ case SWITCH_SIG_KILL:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "%s CHANNEL got SWITCH_SIG_KILL\n",
+ switch_channel_get_name(channel));
+ switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+ switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+ switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+ //switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CHANNEL after TFLAG_HUP\n");
+ //switch_thread_cond_signal(tech_pvt->cond);
+ break;
+ case SWITCH_SIG_BREAK:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "%s CHANNEL got SWITCH_SIG_BREAK\n",
+ switch_channel_get_name(channel));
+ switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+ break;
+ default:
+ break;
+ }
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
+static switch_status_t channel_on_exchange_media(switch_core_session_t * session)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
- return SWITCH_STATUS_SUCCESS;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_on_soft_execute(switch_core_session_t *session)
+static switch_status_t channel_on_soft_execute(switch_core_session_t * session)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
- return SWITCH_STATUS_SUCCESS;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
+static switch_status_t channel_send_dtmf(switch_core_session_t * session,
+ const switch_dtmf_t * dtmf)
{
- private_t *tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
+ private_t *tech_pvt = switch_core_session_get_private(session);
+ switch_assert(tech_pvt != NULL);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
-{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- //switch_time_t started = switch_time_now();
- //unsigned int elapsed;
- switch_byte_t *data;
-
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- tech_pvt->read_frame.flags = SFF_NONE;
- *frame = NULL;
+static switch_status_t channel_read_frame(switch_core_session_t * session,
+ switch_frame_t ** frame, switch_io_flag_t flags,
+ int stream_id)
+{
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
+ //switch_time_t started = switch_time_now();
+ //unsigned int elapsed;
+ switch_byte_t *data;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
+ tech_pvt->read_frame.flags = SFF_NONE;
+ *frame = NULL;
+ if (skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS) {
-if ( skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS ) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "skypiax_skypeaudio_read ERROR\n");
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read ERROR\n");
-
-} else {
- switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n");
-
-}
+ } else {
+ switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n");
- while (switch_test_flag(tech_pvt, TFLAG_IO)) {
- if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
- switch_clear_flag(tech_pvt, TFLAG_BREAK);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FRAME goto CNG\n");
- goto cng;
- }
+ }
- if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FRAME not IO\n");
- return SWITCH_STATUS_FALSE;
- }
+ while (switch_test_flag(tech_pvt, TFLAG_IO)) {
+ if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
+ switch_clear_flag(tech_pvt, TFLAG_BREAK);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "CHANNEL READ FRAME goto CNG\n");
+ goto cng;
+ }
+ if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "CHANNEL READ FRAME not IO\n");
+ return SWITCH_STATUS_FALSE;
+ }
#if 0
- if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
- DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
- SAMPLES_PER_FRAME * sizeof(short));
- switch_sleep(100);
- //do nothing
- } else {
- //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- f.frametype = SKYPIAX_FRAME_VOICE;
- f.subclass = SKYPIAX_FORMAT_SLINEAR;
- f.samples = SKYPIAX_FRAME_SIZE;
- f.datalen = SKYPIAX_FRAME_SIZE * 2;
- f.data = buf;
- f.offset = SKYPIAX_FRIENDLY_OFFSET;
- f.src = skypiax_type;
- f.mallocd = 0;
- }
+ if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
+ DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
+ SAMPLES_PER_FRAME * sizeof(short));
+ switch_sleep(100);
+ //do nothing
+ } else {
+ //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
+ /* A real frame */
+ f.frametype = SKYPIAX_FRAME_VOICE;
+ f.subclass = SKYPIAX_FORMAT_SLINEAR;
+ f.samples = SKYPIAX_FRAME_SIZE;
+ f.datalen = SKYPIAX_FRAME_SIZE * 2;
+ f.data = buf;
+ f.offset = SKYPIAX_FRIENDLY_OFFSET;
+ f.src = skypiax_type;
+ f.mallocd = 0;
+ }
#endif
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n");
-
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n");
- if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- if (!tech_pvt->read_frame.datalen) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ CONTINUE\n");
- continue;
- }
- *frame = &tech_pvt->read_frame;
+ if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
+ switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+ if (!tech_pvt->read_frame.datalen) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "CHANNEL READ CONTINUE\n");
+ continue;
+ }
+ *frame = &tech_pvt->read_frame;
#ifdef BIGENDIAN
- if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
- switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
- }
+ if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+ switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
+ }
#endif
- return SWITCH_STATUS_SUCCESS;
- }
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n");
- return SWITCH_STATUS_FALSE;
+ return SWITCH_STATUS_SUCCESS;
+ }
- }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n");
+ return SWITCH_STATUS_FALSE;
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FALSE\n");
- return SWITCH_STATUS_FALSE;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FALSE\n");
+ return SWITCH_STATUS_FALSE;
- cng:
- data = (switch_byte_t *) tech_pvt->read_frame.data;
- data[0] = 65;
- data[1] = 0;
- tech_pvt->read_frame.datalen = 2;
- tech_pvt->read_frame.flags = SFF_CNG;
- *frame = &tech_pvt->read_frame;
- return SWITCH_STATUS_SUCCESS;
+cng:
+ data = (switch_byte_t *) tech_pvt->read_frame.data;
+ data[0] = 65;
+ data[1] = 0;
+ tech_pvt->read_frame.datalen = 2;
+ tech_pvt->read_frame.flags = SFF_CNG;
+ *frame = &tech_pvt->read_frame;
+ return SWITCH_STATUS_SUCCESS;
}
-static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
-{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- //switch_frame_t *pframe;
- unsigned int sent;
- struct skypiax_interface *p=NULL;
+static switch_status_t channel_write_frame(switch_core_session_t * session,
+ switch_frame_t * frame, switch_io_flag_t flags,
+ int stream_id)
+{
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
+ //switch_frame_t *pframe;
+ unsigned int sent;
+ struct skypiax_interface *p = NULL;
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- p=tech_pvt->p;
- assert(p != NULL);
+ p = tech_pvt->p;
+ assert(p != NULL);
- if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+ if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
ERRORA("CIAPA \n", SKYPIAX_P_LOG);
- return SWITCH_STATUS_FALSE;
- }
+ return SWITCH_STATUS_FALSE;
+ }
#ifdef BIGENDIAN
- if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
- switch_swap_linear(frame->data, (int) frame->datalen / 2);
- }
+ if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
+ switch_swap_linear(frame->data, (int) frame->datalen / 2);
+ }
#endif
- sent = frame->datalen;
- switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
- //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
+ sent = frame->datalen;
+ switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
+ //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
-
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
@@ -1407,12 +1406,13 @@
void create_pipe(void *data)
{
- switch_status_t rv;
+ switch_status_t rv;
+
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&readp, &writep, 2, module_pool);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+}
- //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
- rv = switch_file_pipe_create_ex(&readp, &writep, 2, module_pool);
- //rv = switch_file_pipe_create(&readp, &writep, module_pool);
-}
#if 0
//testpipe.c
@@ -1445,325 +1445,325 @@
static apr_file_t *readp = NULL;
static apr_file_t *writep = NULL;
-static void create_pipe(abts_case *tc, void *data)
+static void create_pipe(abts_case * tc, void *data)
{
- apr_status_t rv;
+ apr_status_t rv;
- rv = apr_file_pipe_create(&readp, &writep, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
-}
-
-static void close_pipe(abts_case *tc, void *data)
-{
- apr_status_t rv;
- apr_size_t nbytes = 256;
- char buf[256];
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+}
- rv = apr_file_close(readp);
- rv = apr_file_close(writep);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+static void close_pipe(abts_case * tc, void *data)
+{
+ apr_status_t rv;
+ apr_size_t nbytes = 256;
+ char buf[256];
- rv = apr_file_read(readp, buf, &nbytes);
- ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
-}
+ rv = apr_file_close(readp);
+ rv = apr_file_close(writep);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-static void set_timeout(abts_case *tc, void *data)
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
+}
+
+static void set_timeout(abts_case * tc, void *data)
{
- apr_status_t rv;
- apr_interval_time_t timeout;
+ apr_status_t rv;
+ apr_interval_time_t timeout;
- rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
- rv = apr_file_pipe_timeout_get(writep, &timeout);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1);
+ rv = apr_file_pipe_timeout_get(writep, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1);
- rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- rv = apr_file_pipe_timeout_get(readp, &timeout);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second",
- timeout == apr_time_from_sec(1));
+ rv = apr_file_pipe_timeout_get(readp, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second", timeout == apr_time_from_sec(1));
}
-static void read_write(abts_case *tc, void *data)
+static void read_write(abts_case * tc, void *data)
{
- apr_status_t rv;
- char *buf;
- apr_size_t nbytes;
-
- nbytes = strlen("this is a test");
- buf = (char *)apr_palloc(p, nbytes + 1);
+ apr_status_t rv;
+ char *buf;
+ apr_size_t nbytes;
- rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
+ nbytes = strlen("this is a test");
+ buf = (char *) apr_palloc(p, nbytes + 1);
- rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
- if (!rv) {
- rv = apr_file_read(readp, buf, &nbytes);
- ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
- ABTS_SIZE_EQUAL(tc, 0, nbytes);
- }
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ if (!rv) {
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
+ ABTS_SIZE_EQUAL(tc, 0, nbytes);
+ }
}
-static void read_write_notimeout(abts_case *tc, void *data)
+static void read_write_notimeout(abts_case * tc, void *data)
{
- apr_status_t rv;
- char *buf = "this is a test";
- char *input;
- apr_size_t nbytes;
-
- nbytes = strlen("this is a test");
+ apr_status_t rv;
+ char *buf = "this is a test";
+ char *input;
+ apr_size_t nbytes;
- rv = apr_file_pipe_create(&readp, &writep, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_PTR_NOTNULL(tc, readp);
- ABTS_PTR_NOTNULL(tc, writep);
+ nbytes = strlen("this is a test");
- rv = apr_file_write(writep, buf, &nbytes);
- ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
- nbytes = 256;
- input = apr_pcalloc(p, nbytes + 1);
- rv = apr_file_read(readp, input, &nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
- ABTS_STR_EQUAL(tc, "this is a test", input);
+ rv = apr_file_write(writep, buf, &nbytes);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ nbytes = 256;
+ input = apr_pcalloc(p, nbytes + 1);
+ rv = apr_file_read(readp, input, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_STR_EQUAL(tc, "this is a test", input);
}
-static void test_pipe_writefull(abts_case *tc, void *data)
+static void test_pipe_writefull(abts_case * tc, void *data)
{
- int iterations = 1000;
- int i;
- int bytes_per_iteration = 8000;
- char *buf = (char *)malloc(bytes_per_iteration);
- char responsebuf[128];
- apr_size_t nbytes;
- int bytes_processed;
- apr_proc_t proc = {0};
- apr_procattr_t *procattr;
- const char *args[2];
- apr_status_t rv;
- apr_exit_why_e why;
-
- rv = apr_procattr_create(&procattr, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK,
- APR_CHILD_BLOCK);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ int iterations = 1000;
+ int i;
+ int bytes_per_iteration = 8000;
+ char *buf = (char *) malloc(bytes_per_iteration);
+ char responsebuf[128];
+ apr_size_t nbytes;
+ int bytes_processed;
+ apr_proc_t proc = { 0 };
+ apr_procattr_t *procattr;
+ const char *args[2];
+ apr_status_t rv;
+ apr_exit_why_e why;
+
+ rv = apr_procattr_create(&procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK, APR_CHILD_BLOCK);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_error_check_set(procattr, 1);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ args[0] = "readchild" EXTENSION;
+ args[1] = NULL;
+ rv = apr_proc_create(&proc, TESTBINPATH "readchild" EXTENSION, args, NULL, procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- rv = apr_procattr_error_check_set(procattr, 1);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- args[0] = "readchild" EXTENSION;
- args[1] = NULL;
- rv = apr_proc_create(&proc, TESTBINPATH "readchild" EXTENSION, args, NULL, procattr, p);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
+ i = iterations;
+ do {
+ rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ } while (--i);
- rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ free(buf);
- i = iterations;
- do {
- rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- } while (--i);
+ rv = apr_file_close(proc.in);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- free(buf);
+ nbytes = sizeof(responsebuf);
+ rv = apr_file_read(proc.out, responsebuf, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ bytes_processed = (int) apr_strtoi64(responsebuf, NULL, 10);
+ ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
- rv = apr_file_close(proc.in);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-
- nbytes = sizeof(responsebuf);
- rv = apr_file_read(proc.out, responsebuf, &nbytes);
- ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
- bytes_processed = (int)apr_strtoi64(responsebuf, NULL, 10);
- ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
+ ABTS_ASSERT(tc, "wait for child process",
+ apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
- ABTS_ASSERT(tc, "wait for child process",
- apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
-
- ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
+ ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
}
-abts_suite *testpipe(abts_suite *suite)
+abts_suite *testpipe(abts_suite * suite)
{
- suite = ADD_SUITE(suite)
+ suite = ADD_SUITE(suite)
abts_run_test(suite, create_pipe, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, set_timeout, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, read_write, NULL);
- abts_run_test(suite, close_pipe, NULL);
- abts_run_test(suite, read_write_notimeout, NULL);
- abts_run_test(suite, test_pipe_writefull, NULL);
- abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, set_timeout, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write_notimeout, NULL);
+ abts_run_test(suite, test_pipe_writefull, NULL);
+ abts_run_test(suite, close_pipe, NULL);
- return suite;
+ return suite;
}
-
-
-
#endif
-
#endif
-static switch_status_t channel_answer_channel(switch_core_session_t *session)
+static switch_status_t channel_answer_channel(switch_core_session_t * session)
{
- private_t *tech_pvt;
- switch_channel_t *channel = NULL;
- struct skypiax_interface *p;
+ private_t *tech_pvt;
+ switch_channel_t *channel = NULL;
+ struct skypiax_interface *p;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- p=tech_pvt->p;
+ p = tech_pvt->p;
- DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-
-static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
+static switch_status_t channel_receive_message(switch_core_session_t * session,
+ switch_core_session_message_t * msg)
{
- switch_channel_t *channel;
- private_t *tech_pvt;
- struct skypiax_interface *p;
+ switch_channel_t *channel;
+ private_t *tech_pvt;
+ struct skypiax_interface *p;
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- tech_pvt = (private_t *) switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
+ tech_pvt = (private_t *) switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- p=tech_pvt->p;
+ p = tech_pvt->p;
- switch (msg->message_id) {
- case SWITCH_MESSAGE_INDICATE_ANSWER:
- {
- //WARNINGA("TO BE ANSWERED! \n", SKYPIAX_P_LOG);
- DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
- channel_answer_channel(session);
- }
- break;
- default:
- {
- WARNINGA("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id);
- }
- break;
- }
+ switch (msg->message_id) {
+ case SWITCH_MESSAGE_INDICATE_ANSWER:
+ {
+ //WARNINGA("TO BE ANSWERED! \n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
+ channel_answer_channel(session);
+ }
+ break;
+ default:
+ {
+ WARNINGA("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id);
+ }
+ break;
+ }
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
+
#if 0
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
- switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
-{
- if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
- private_t *tech_pvt;
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
-
- switch_core_session_add_stream(*new_session, NULL);
- if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = SKYPIAX_INTERFACES[2]; //FIXME
- channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session, NULL);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
- if (outbound_profile) {
- char name[128];
-
- snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
- switch_channel_set_name(channel, name);
-
- caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
- switch_channel_set_caller_profile(channel, caller_profile);
- tech_pvt->caller_profile = caller_profile;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
-
- skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30);
-
- switch_channel_set_flag(channel, CF_OUTBOUND);
- switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
- switch_channel_set_state(channel, CS_INIT);
- return SWITCH_CAUSE_SUCCESS;
- }
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
+ switch_event_t * var_event,
+ switch_caller_profile_t *
+ outbound_profile,
+ switch_core_session_t ** new_session,
+ switch_memory_pool_t ** pool,
+ switch_originate_flag_t flags)
+{
+ if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
+ private_t *tech_pvt;
+ switch_channel_t *channel;
+ switch_caller_profile_t *caller_profile;
+
+ switch_core_session_add_stream(*new_session, NULL);
+ if ((tech_pvt =
+ (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
+ tech_pvt->p = SKYPIAX_INTERFACES[2]; //FIXME
+ channel = switch_core_session_get_channel(*new_session);
+ tech_init(tech_pvt, *new_session, NULL);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Hey where is my memory pool?\n");
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
+
+ if (outbound_profile) {
+ char name[128];
+
+ snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
+ switch_channel_set_name(channel, name);
+
+ caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
+ switch_channel_set_caller_profile(channel, caller_profile);
+ tech_pvt->caller_profile = caller_profile;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
+
+ skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30);
+
+ switch_channel_set_flag(channel, CF_OUTBOUND);
+ switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
+ switch_channel_set_state(channel, CS_INIT);
+ return SWITCH_CAUSE_SUCCESS;
+ }
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
#endif // 0 //FIXME: moved below
-static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
+static switch_status_t channel_receive_event(switch_core_session_t * session,
+ switch_event_t * event)
{
- struct private_object *tech_pvt = switch_core_session_get_private(session);
- char *body = switch_event_get_body(event);
- switch_assert(tech_pvt != NULL);
+ struct private_object *tech_pvt = switch_core_session_get_private(session);
+ char *body = switch_event_get_body(event);
+ switch_assert(tech_pvt != NULL);
- if (!body) {
- body = "";
- }
+ if (!body) {
+ body = "";
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event: |||%s|||\n", body);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event: |||%s|||\n", body);
- return SWITCH_STATUS_SUCCESS;
+ return SWITCH_STATUS_SUCCESS;
}
-
-
switch_state_handler_table_t skypiax_state_handlers = {
- /*.on_init */ channel_on_init,
- /*.on_routing */ channel_on_routing,
- /*.on_execute */ channel_on_execute,
- /*.on_hangup */ channel_on_hangup,
- /*.on_exchange_media */ channel_on_exchange_media,
- /*.on_soft_execute */ channel_on_soft_execute
+ /*.on_init */ channel_on_init,
+ /*.on_routing */ channel_on_routing,
+ /*.on_execute */ channel_on_execute,
+ /*.on_hangup */ channel_on_hangup,
+ /*.on_exchange_media */ channel_on_exchange_media,
+ /*.on_soft_execute */ channel_on_soft_execute
};
switch_io_routines_t skypiax_io_routines = {
- /*.outgoing_channel */ channel_outgoing_channel,
- /*.read_frame */ channel_read_frame,
- /*.write_frame */ channel_write_frame,
- /*.kill_channel */ channel_kill_channel,
- /*.send_dtmf */ channel_send_dtmf,
- /*.receive_message */ channel_receive_message,
- /*.receive_event */ channel_receive_event
+ /*.outgoing_channel */ channel_outgoing_channel,
+ /*.read_frame */ channel_read_frame,
+ /*.write_frame */ channel_write_frame,
+ /*.kill_channel */ channel_kill_channel,
+ /*.send_dtmf */ channel_send_dtmf,
+ /*.receive_message */ channel_receive_message,
+ /*.receive_event */ channel_receive_event
};
+
#define SKYPE_THREAD
#ifndef WIN32_SKYPIAX
#ifdef SKYPE_THREAD
@@ -1899,7 +1899,7 @@
switch_sleep(1000);
}
-static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
+static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
{
struct skypiax_interface *p;
@@ -1911,7 +1911,7 @@
//int res;
p = obj;
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
/*
if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
@@ -1923,28 +1923,31 @@
}
*/
- switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
+ &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
#if 0
res = pipe(p->AsteriskHandlesAst.fdesc);
if (res) {
ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
+ return NULL;
}
fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
#endif
-
AsteriskHandlesAst = &p->AsteriskHandlesAst;
//disp = XOpenDisplay(getenv("DISPLAY"));
disp = XOpenDisplay(p->X11_display);
if (!disp) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open X Display '%s', exiting skype thread\n", p->X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Cannot open X Display '%s', exiting skype thread\n",
+ p->X11_display);
return NULL;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n", p->X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n",
+ p->X11_display);
}
int xfd;
@@ -1977,7 +1980,7 @@
SKYPIAX_P_LOG);
//p->skype = 0;
//p->skype_thread = SKYPIAX_PTHREADT_NULL;
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1988,7 +1991,7 @@
SKYPIAX_P_LOG);
//p->skype = 0;
//p->skype_thread = SKYPIAX_PTHREADT_NULL;
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -2022,9 +2025,9 @@
strcat(buffer, buf);
if (i < 20) { /* last fragment */
- unsigned int howmany;
+ unsigned int howmany;
- howmany = strlen(b) + 1;
+ howmany = strlen(b) + 1;
switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany);
//write(AsteriskHandlesAst->fdesc[1], "\0", 1);
@@ -2049,17 +2052,14 @@
//p->skype = 0;
//p->skype_thread = SKYPIAX_PTHREADT_NULL;
//pthread_cleanup_pop(1);
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
-
#endif /* SKYPE_THREAD */
#else // WIN32_SKYPIAX
-
-
#endif // WIN32_SKYPIAX
#define CONTROLDEV_THREAD
@@ -2109,9 +2109,9 @@
}
AsteriskHandlesAst = &p->AsteriskHandlesAst;
- if (option_debug > 101) {
- DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
- }
+ if (option_debug > 101) {
+ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+ }
if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) {
ERRORA
@@ -2135,7 +2135,6 @@
}
#endif //0
-
int skypiax_skype_read(struct skypiax_interface *p)
{
@@ -2154,7 +2153,7 @@
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
- //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
//switch_sleep(1000000);
memset(read_from_pipe, 0, 4096);
@@ -2169,10 +2168,10 @@
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
#endif
- rt=1;
+ rt = 1;
if (rt > 0) {
howmany = sizeof(read_from_pipe);
- switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
+ switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
a = 0;
for (i = 0; i < howmany; i++) {
@@ -2185,7 +2184,7 @@
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
-#if 0 //FIXME wat's the use of this?
+#if 0 //FIXME wat's the use of this?
if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
just authorized */
NOTICA
@@ -2198,25 +2197,24 @@
#endif
if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
- ERRORA
- ("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, messaggio);
- p->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- p->skype_call_id[0] = '\0';
-
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
- }
+ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ p->skype_call_id[0] = '\0';
+
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ //FIXME if(p->owner)
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ }
}
strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
@@ -2247,26 +2245,24 @@
strncpy(p->skype_displayname, &messaggio_2[10], 511);
}
if (!strcasecmp(messaggio, "ERROR")) {
- ERRORA
- ("Skype got ERROR: |||%s|||\n",
- SKYPIAX_P_LOG, messaggio);
- p->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- p->skype_call_id[0] = '\0';
-
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- p->interface_state = SKYPIAX_STATE_DOWN;
- //FIXME if(p->owner){
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
- //FIXME }
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
- }
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ p->skype_call_id[0] = '\0';
+
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ //FIXME if(p->owner){
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ //FIXME }
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ }
}
if (!strcasecmp(messaggio, "CALL")) {
@@ -2293,13 +2289,17 @@
if (!strcasecmp(prop, "PARTNER_HANDLE")) {
strncpy(p->callid_number, value, sizeof(p->callid_number) - 1);
- WARNINGA("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n", SKYPIAX_P_LOG, id, p->callid_number);
+ WARNINGA
+ ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n",
+ SKYPIAX_P_LOG, id, p->callid_number);
return CALLFLOW_INCOMING_RING;
}
if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value,
where ? " " : "", where ? where : "");
- WARNINGA("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n", SKYPIAX_P_LOG, id, p->callid_name);
+ WARNINGA
+ ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n",
+ SKYPIAX_P_LOG, id, p->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,
@@ -2313,32 +2313,30 @@
p->interface_state = SKYPIAX_STATE_PRERING;
}
- if (!strcasecmp(prop, "DTMF")) {
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
+ if (!strcasecmp(prop, "DTMF")) {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
//FIXME struct ast_frame f2 = { SKYPIAX_FRAME_DTMF, value[0], };
DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
- tech_pvt = p->tech_pvt;
- session = tech_pvt->session;
- channel = switch_core_session_get_channel(session);
-
-
-
- if (channel) {
- switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
- if (globals.debug) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel));
- }
- switch_mutex_lock(tech_pvt->flag_mutex);
- switch_channel_queue_dtmf(channel, &dtmf);
- switch_set_flag(tech_pvt, TFLAG_DTMF);
- switch_mutex_unlock(tech_pvt->flag_mutex);
- }
-
-
+ tech_pvt = p->tech_pvt;
+ session = tech_pvt->session;
+ channel = switch_core_session_get_channel(session);
+
+ if (channel) {
+ switch_dtmf_t dtmf =
+ { (char) value[0], switch_core_default_dtmf_duration(0) };
+ if (globals.debug) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n",
+ dtmf.digit, switch_channel_get_name(channel));
+ }
+ switch_mutex_lock(tech_pvt->flag_mutex);
+ switch_channel_queue_dtmf(channel, &dtmf);
+ switch_set_flag(tech_pvt, TFLAG_DTMF);
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+ }
//FIXME ast_queue_frame(p->owner, &f2);
}
@@ -2348,7 +2346,7 @@
("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(prop, "DURATION") && (!strcasecmp(value, "1"))) {
if (strcasecmp(id, p->skype_call_id)) {
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
if (option_debug > 1)
@@ -2358,7 +2356,6 @@
}
}
-
if (!strcasecmp(prop, "STATUS")) {
if (!strcasecmp(value, "RINGING")) {
@@ -2417,7 +2414,7 @@
DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "FINISHED")) {
- global_session = NULL; //FIXME
+ global_session = NULL; //FIXME
//p->skype_callflow = CALLFLOW_STATUS_FINISHED;
if (option_debug)
DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
@@ -2429,7 +2426,7 @@
}
//p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2449,7 +2446,7 @@
}
p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
p->interface_state = SKYPIAX_STATE_DOWN;
@@ -2467,7 +2464,7 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
if (!strcasecmp(id, p->skype_call_id)) {
@@ -2484,7 +2481,7 @@
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
/* we're here because were us that refused an incoming call */
@@ -2509,164 +2506,155 @@
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
//FIXME if (p->owner) {
- //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER);
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER);
//FIXME }
if (option_debug > 1)
- DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
- id);
+ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
+ SKYPIAX_P_LOG, id);
//FIXME if (p->owner)
- if (1) {
- char msg_to_skype[1024];
-
-
+ if (1) {
+ char msg_to_skype[1024];
#if 0
- if (!p->tcp_srv_thread) {
- if(1)
- {
+ if (!p->tcp_srv_thread) {
+ if (1) {
#endif
- //switch_thread_t *thread;
- if(1){
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, p, module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+ //switch_thread_t *thread;
+ if (1) {
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_srv_thread, thd_attr,
+ skypiax_do_tcp_srv_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
#if 0
- }
- }
+ }
+ }
#endif
-
-
-
-
-
#if 0
- if (!p->tcp_cli_thread) {
- if(1)
- {
+ if (!p->tcp_cli_thread) {
+ if (1) {
#endif
- //switch_thread_t *thread;
- //switch_threadattr_t *thd_attr = NULL;
+ //switch_thread_t *thread;
+ //switch_threadattr_t *thd_attr = NULL;
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, p, module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_cli_thread, thd_attr,
+ skypiax_do_tcp_cli_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ }
#if 0
- }
-
+ }
- }
+ }
#endif
- switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- }
+ switch_sleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
+ }
p->skype_callflow = SKYPIAX_STATE_UP;
- /**************************/
-
- //FIXME switch_core_session_t **new_session;
-
- //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
-
- if (!global_session) { //FIXME FIXME FIXME
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
-
+ /**************************/
+ //FIXME switch_core_session_t **new_session;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel!\n");
-
- if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
- switch_core_session_add_stream(session, NULL);
- if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
- channel = switch_core_session_get_channel(session);
- tech_init(tech_pvt, session, p);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
- switch_core_session_destroy(&session);
- break;
- }
-
- // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0)
-
- if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
- "skypiax",
- "XML",
- "gmaruzz_from_skype",
- "calling_number",
- NULL,
- "calling_ani",
- NULL,
- NULL,
- (char *) modname,
- "default",
- "5000")) != 0) {
- char name[128];
- switch_snprintf(name, sizeof(name), "skypiax/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
- 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) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
- switch_core_session_destroy(&session);
- }
+ //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
+ if (!global_session) { //FIXME FIXME FIXME
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+ "New Inbound Channel!\n");
+
+ if ((session =
+ switch_core_session_request(skypiax_endpoint_interface,
+ NULL)) != 0) {
+ switch_core_session_add_stream(session, NULL);
+ if ((tech_pvt =
+ (private_t *) switch_core_session_alloc(session,
+ sizeof(private_t))) != 0) {
+ channel = switch_core_session_get_channel(session);
+ tech_init(tech_pvt, session, p);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Hey where is my memory pool?\n");
+ switch_core_session_destroy(&session);
+ break;
+ }
+
+ // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0)
+
+ if ((tech_pvt->caller_profile =
+ switch_caller_profile_new(switch_core_session_get_pool(session),
+ "skypiax", "XML", "gmaruzz_from_skype",
+ "calling_number", NULL, "calling_ani",
+ NULL, NULL, (char *) modname, "default",
+ "5000")) != 0) {
+ char name[128];
+ switch_snprintf(name, sizeof(name), "skypiax/%s-%04x",
+ tech_pvt->caller_profile->destination_number,
+ rand() & 0xffff);
+ 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) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Error spawning thread\n");
+ switch_core_session_destroy(&session);
+ }
#if 0
- if (iax_set_codec(tech_pvt, iaxevent->session,
- &iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
- iax_reject(iaxevent->session, "Codec Error!");
- switch_core_session_destroy(&session);
- } else {
- tech_pvt->iax_session = iaxevent->session;
- tech_pvt->session = session;
- iax_accept(tech_pvt->iax_session, tech_pvt->codec);
- iax_ring_announce(tech_pvt->iax_session);
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
- switch_core_session_destroy(&session);
- }
- }
+ if (iax_set_codec
+ (tech_pvt, iaxevent->session, &iaxevent->ies.format,
+ &iaxevent->ies.capability, &iaxevent->ies.samprate,
+ IAX_SET) != SWITCH_STATUS_SUCCESS) {
+ iax_reject(iaxevent->session, "Codec Error!");
+ switch_core_session_destroy(&session);
+ } else {
+ tech_pvt->iax_session = iaxevent->session;
+ tech_pvt->session = session;
+ iax_accept(tech_pvt->iax_session, tech_pvt->codec);
+ iax_ring_announce(tech_pvt->iax_session);
+ switch_channel_set_state(channel, CS_INIT);
+ if (switch_core_session_thread_launch(session) !=
+ SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Error spawning thread\n");
+ switch_core_session_destroy(&session);
+ }
+ }
#endif //0
- }
- } else {
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
-
- tech_pvt = p->tech_pvt;
- //session = tech_pvt->session;
- session = global_session;
- channel = switch_core_session_get_channel(session);
- switch_channel_mark_pre_answered(channel);
-
- //switch_channel_set_state(channel, CS_EXECUTE);
-
- }
- /**************************/
-
-
-
+ }
+ } else {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+ tech_pvt = p->tech_pvt;
+ //session = tech_pvt->session;
+ session = global_session;
+ channel = switch_core_session_get_channel(session);
+ switch_channel_mark_pre_answered(channel);
+ //switch_channel_set_state(channel, CS_EXECUTE);
+ }
+ /**************************/
} else {
WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
@@ -2686,11 +2674,12 @@
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return 0;
}
-int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session)
+int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
+ switch_core_session_t * session)
{
char rdest[80];
char msg_to_skype[1024];
@@ -2698,7 +2687,7 @@
if (option_debug > 10) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
-switch_sleep(5000);
+ switch_sleep(5000);
//FIXME strncpy(rdest, idest, sizeof(rdest) - 1);
strncpy(rdest, "echo123", sizeof(rdest) - 1);
@@ -2736,51 +2725,57 @@
return 0;
}
-static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
- switch_caller_profile_t *outbound_profile,
- switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
-{
- if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
- private_t *tech_pvt;
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
-
- switch_core_session_add_stream(*new_session, NULL);
- if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME
- channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session, NULL);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
- if (outbound_profile) {
- char name[128];
-
- snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
- switch_channel_set_name(channel, name);
-
- caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
- switch_channel_set_caller_profile(channel, caller_profile);
- tech_pvt->caller_profile = caller_profile;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
-
-
- skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30, *new_session);
-
- switch_channel_set_flag(channel, CF_OUTBOUND);
- switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
- switch_channel_set_state(channel, CS_INIT);
- return SWITCH_CAUSE_SUCCESS;
- }
+static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session,
+ switch_event_t * var_event,
+ switch_caller_profile_t *
+ outbound_profile,
+ switch_core_session_t ** new_session,
+ switch_memory_pool_t ** pool,
+ switch_originate_flag_t flags)
+{
+ if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) {
+ private_t *tech_pvt;
+ switch_channel_t *channel;
+ switch_caller_profile_t *caller_profile;
+
+ switch_core_session_add_stream(*new_session, NULL);
+ if ((tech_pvt =
+ (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
+ tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME
+ channel = switch_core_session_get_channel(*new_session);
+ tech_init(tech_pvt, *new_session, NULL);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Hey where is my memory pool?\n");
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
+
+ if (outbound_profile) {
+ char name[128];
+
+ snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
+ switch_channel_set_name(channel, name);
+
+ caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
+ switch_channel_set_caller_profile(channel, caller_profile);
+ tech_pvt->caller_profile = caller_profile;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
+
+ skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30,
+ *new_session);
+
+ switch_channel_set_flag(channel, CF_OUTBOUND);
+ switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
+ switch_channel_set_state(channel, CS_INIT);
+ return SWITCH_CAUSE_SUCCESS;
+ }
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
@@ -2788,301 +2783,336 @@
* \brief This thread runs during a call, and monitor the interface serial port for signaling, like hangup, caller id, etc
*
*/
-static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t *thread, void *obj)
+static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t * thread,
+ void *obj)
//void *skypiax_do_controldev_thread(void *data)
{
struct skypiax_interface *p = obj;
int res;
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-
- DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, (void *)p);
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG,
+ (void *) p);
while (1) {
switch_sleep(1000);
res = skypiax_skype_read(p);
#if 1
- //if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
- if (res == CALLFLOW_INCOMING_HANGUP) {
- switch_core_session_t *session = NULL;
- private_t *tech_pvt;
- switch_channel_t *channel;
+ //if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
+ if (res == CALLFLOW_INCOMING_HANGUP) {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt;
+ switch_channel_t *channel;
+ //p->interface_state=SKYPIAX_STATE_DOWN;
+ //if (option_debug)
+ DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
- //p->interface_state=SKYPIAX_STATE_DOWN;
- //if (option_debug)
- DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
+ tech_pvt = p->tech_pvt;
+ session = tech_pvt->session;
- tech_pvt = p->tech_pvt;
- session = tech_pvt->session;
-
- channel = switch_core_session_get_channel(session);
- DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
+ channel = switch_core_session_get_channel(session);
+ DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
- //switch_channel_set_state(channel, CS_HANGUP);
+ //switch_channel_set_state(channel, CS_HANGUP);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
- //DEBUGA_SKYPE("set state to CS_HANGUP\n", SKYPIAX_P_LOG);
- }
+ //DEBUGA_SKYPE("set state to CS_HANGUP\n", SKYPIAX_P_LOG);
+ }
#endif
}
//if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
//}
return NULL;
}
-
#endif // CONTROLDEV_THREAD
static switch_status_t load_config(void)
{
- char *cf = "skypiax.conf";
- switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
+ char *cf = "skypiax.conf";
+ switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
+
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+ if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+ return SWITCH_STATUS_TERM;
+ }
+
+ if ((global_settings = switch_xml_child(cfg, "global_settings"))) {
+ for (param = switch_xml_child(global_settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcasecmp(var, "debug")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n",
+ globals.debug);
+ globals.debug = atoi(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n",
+ globals.debug);
+ } else if (!strcasecmp(var, "hold-music")) {
+ switch_set_string(globals.hold_music, val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.hold_music=%s\n",
+ globals.hold_music);
+ } else if (!strcmp(var, "port")) {
+ globals.port = atoi(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.port=%d\n",
+ globals.port);
+ } else if (!strcmp(var, "ip")) {
+ set_global_ip(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.ip=%s\n",
+ globals.ip);
+ } else if (!strcmp(var, "codec-master")) {
+ if (!strcasecmp(val, "us")) {
+ switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS);
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "codec-master globals.debug=%d\n", globals.debug);
+ } else if (!strcmp(var, "dialplan")) {
+ set_global_dialplan(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.dialplan=%s\n",
+ globals.dialplan);
+ } else if (!strcmp(var, "codec-prefs")) {
+ set_global_codec_string(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "globals.codec_string=%s\n", globals.codec_string);
+ globals.codec_order_last =
+ switch_separate_string(globals.codec_string, ',', globals.codec_order,
+ SWITCH_MAX_CODECS);
+ } else if (!strcmp(var, "codec-rates")) {
+ set_global_codec_rates_string(val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "globals.codec_rates_string=%s\n", globals.codec_rates_string);
+ globals.codec_rates_last =
+ switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates,
+ SWITCH_MAX_CODECS);
+ }
+
+ }
+ }
+
+ if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
+ int i = 0;
+
+ for (myinterface = switch_xml_child(interfaces, "interface"); myinterface;
+ myinterface = myinterface->next) {
+ char *id = (char *) switch_xml_attr(myinterface, "id");
+ char *name = (char *) switch_xml_attr(myinterface, "name");
+ char *context = "default";
+ char *dialplan = "XML";
+ char *tonegroup = NULL;
+ char *digit_timeout = NULL;
+ char *max_digits = NULL;
+ char *hotline = NULL;
+ char *dial_regex = NULL;
+ char *hold_music = NULL;
+ char *fail_dial_regex = NULL;
+ char *enable_callerid = "true";
+ char *X11_display = NULL;
+
+ uint32_t interface_id = 0, to = 0, max = 0;
+
+ for (param = switch_xml_child(myinterface, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcasecmp(var, "tonegroup")) {
+ tonegroup = val;
+ } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) {
+ digit_timeout = val;
+ } else if (!strcasecmp(var, "context")) {
+ context = val;
+ } else if (!strcasecmp(var, "dialplan")) {
+ dialplan = val;
+ } else if (!strcasecmp(var, "dial-regex")) {
+ dial_regex = val;
+ } else if (!strcasecmp(var, "enable-callerid")) {
+ enable_callerid = val;
+ } else if (!strcasecmp(var, "fail-dial-regex")) {
+ fail_dial_regex = val;
+ } else if (!strcasecmp(var, "hold-music")) {
+ hold_music = val;
+ } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) {
+ X11_display = val;
+ } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
+ max_digits = val;
+ } else if (!strcasecmp(var, "hotline")) {
+ hotline = val;
+ }
- switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
- if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
- return SWITCH_STATUS_TERM;
- }
-
- if ((global_settings = switch_xml_child(cfg, "global_settings"))) {
- for (param = switch_xml_child(global_settings, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
-
- if (!strcasecmp(var, "debug")) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
- globals.debug = atoi(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
- } else if (!strcasecmp(var, "hold-music")) {
- switch_set_string(globals.hold_music, val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.hold_music=%s\n", globals.hold_music);
- } else if (!strcmp(var, "port")) {
- globals.port = atoi(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.port=%d\n", globals.port);
- } else if (!strcmp(var, "ip")) {
- set_global_ip(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.ip=%s\n", globals.ip);
- } else if (!strcmp(var, "codec-master")) {
- if (!strcasecmp(val, "us")) {
- switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS);
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "codec-master globals.debug=%d\n", globals.debug);
- } else if (!strcmp(var, "dialplan")) {
- set_global_dialplan(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.dialplan=%s\n", globals.dialplan);
- } else if (!strcmp(var, "codec-prefs")) {
- set_global_codec_string(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.codec_string=%s\n", globals.codec_string);
- globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS);
- } else if (!strcmp(var, "codec-rates")) {
- set_global_codec_rates_string(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.codec_rates_string=%s\n", globals.codec_rates_string);
- globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS);
- }
-
- }
- }
-
- if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
- int i=0;
-
- for (myinterface = switch_xml_child(interfaces, "interface"); myinterface; myinterface = myinterface->next) {
- char *id = (char *) switch_xml_attr(myinterface, "id");
- char *name = (char *) switch_xml_attr(myinterface, "name");
- char *context = "default";
- char *dialplan = "XML";
- char *tonegroup = NULL;
- char *digit_timeout = NULL;
- char *max_digits = NULL;
- char *hotline = NULL;
- char *dial_regex = NULL;
- char *hold_music = NULL;
- char *fail_dial_regex = NULL;
- char *enable_callerid = "true";
- char *X11_display = NULL;
-
- uint32_t interface_id = 0, to = 0, max = 0;
-
- for (param = switch_xml_child(myinterface, "param"); param; param = param->next) {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
-
- if (!strcasecmp(var, "tonegroup")) {
- tonegroup = val;
- } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) {
- digit_timeout = val;
- } else if (!strcasecmp(var, "context")) {
- context = val;
- } else if (!strcasecmp(var, "dialplan")) {
- dialplan = val;
- } else if (!strcasecmp(var, "dial-regex")) {
- dial_regex = val;
- } else if (!strcasecmp(var, "enable-callerid")) {
- enable_callerid = val;
- } else if (!strcasecmp(var, "fail-dial-regex")) {
- fail_dial_regex = val;
- } else if (!strcasecmp(var, "hold-music")) {
- hold_music = val;
- } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) {
- X11_display = val;
- } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
- max_digits = val;
- } else if (!strcasecmp(var, "hotline")) {
- hotline = val;
- }
-
- }
-
- if (!X11_display) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'X11_display'\n");
- continue;
- }
-
- if (!id) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'id'\n");
- continue;
- }
- if (switch_is_number(id)) {
- interface_id = atoi(id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d\n", interface_id);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface param 'id' MUST be a number, now id='%s'\n", id);
- continue;
- }
-
-
- if (!name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "interface missing param 'name', not nice, but works\n");
- }
-
- if (!tonegroup) {
- tonegroup = "us";
- }
-
- if (digit_timeout) {
- to = atoi(digit_timeout);
- }
-
- if (max_digits) {
- max = atoi(max_digits);
- }
-
- if (name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
- }
- if(interface_id && interface_id < SKYPIAX_MAX_INTERFACES ) {
- struct skypiax_interface newconf;
- memset(&newconf, '\0', sizeof(newconf));
- SKYPIAX_INTERFACES[interface_id]=newconf;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING interface_id=%d\n", interface_id);
- switch_set_string(SKYPIAX_INTERFACES[interface_id].interface_id, id);
- if (name) {
- switch_set_string(SKYPIAX_INTERFACES[interface_id].name, name);
- } else {
- switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A");
- }
- switch_set_string(SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
- switch_set_string(SKYPIAX_INTERFACES[interface_id].context, context);
- switch_set_string(SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].name=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].context=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id);
-
-
-if(1)
-{
- switch_thread_t *thread;
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
-}
-
-switch_sleep(100000);
-if(1)
-{
- switch_thread_t *thread;
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
-}
-
-
-switch_sleep(1000000);
-
-skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED interface_id=%d\n", interface_id);
-
-
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", interface_id, SKYPIAX_MAX_INTERFACES);
- continue;
- }
-
- }
-
- for(i=0; i < SKYPIAX_MAX_INTERFACES; i++) {
- if(strlen(SKYPIAX_INTERFACES[i].name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i, SKYPIAX_INTERFACES[i].interface_id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i, SKYPIAX_INTERFACES[i].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].name=%s\n", i, i, SKYPIAX_INTERFACES[i].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].context=%s\n", i, i, SKYPIAX_INTERFACES[i].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i, SKYPIAX_INTERFACES[i].dialplan);
- }
- }
- }
+ }
+
+ if (!X11_display) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface missing REQUIRED param 'X11_display'\n");
+ continue;
+ }
+
+ if (!id) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface missing REQUIRED param 'id'\n");
+ continue;
+ }
+ if (switch_is_number(id)) {
+ interface_id = atoi(id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d\n",
+ interface_id);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface param 'id' MUST be a number, now id='%s'\n", id);
+ continue;
+ }
+
+ if (!name) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+ "interface missing param 'name', not nice, but works\n");
+ }
- switch_xml_free(xml);
+ if (!tonegroup) {
+ tonegroup = "us";
+ }
+
+ if (digit_timeout) {
+ to = atoi(digit_timeout);
+ }
- return SWITCH_STATUS_SUCCESS;
+ if (max_digits) {
+ max = atoi(max_digits);
+ }
+
+ if (name) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
+ }
+ if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
+ struct skypiax_interface newconf;
+ memset(&newconf, '\0', sizeof(newconf));
+ SKYPIAX_INTERFACES[interface_id] = newconf;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "CONFIGURING interface_id=%d\n", interface_id);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].interface_id, id);
+ if (name) {
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, name);
+ } else {
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A");
+ }
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].context, context);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d SKYPIAX_INTERFACES[interface_id].X11_display=%s\n",
+ interface_id, SKYPIAX_INTERFACES[interface_id].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d SKYPIAX_INTERFACES[interface_id].name=%s\n",
+ interface_id, SKYPIAX_INTERFACES[interface_id].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d SKYPIAX_INTERFACES[interface_id].context=%s\n",
+ interface_id, SKYPIAX_INTERFACES[interface_id].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d SKYPIAX_INTERFACES[interface_id].dialplan=%s\n",
+ interface_id, SKYPIAX_INTERFACES[interface_id].dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ "STARTING interface_id=%d\n", interface_id);
+
+ if (1) {
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&thread, thd_attr, do_skype_thread,
+ &SKYPIAX_INTERFACES[interface_id], module_pool);
+ }
+
+ switch_sleep(100000);
+ if (1) {
+ switch_thread_t *thread;
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread,
+ &SKYPIAX_INTERFACES[interface_id], module_pool);
+ }
+
+ switch_sleep(1000000);
+
+ skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+ "STARTED interface_id=%d\n", interface_id);
+
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n",
+ interface_id, SKYPIAX_MAX_INTERFACES);
+ continue;
+ }
+
+ }
+
+ for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
+ if (strlen(SKYPIAX_INTERFACES[i].name)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "i=%d SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i,
+ SKYPIAX_INTERFACES[i].interface_id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "i=%d SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i,
+ SKYPIAX_INTERFACES[i].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "i=%d SKYPIAX_INTERFACES[%d].name=%s\n", i, i,
+ SKYPIAX_INTERFACES[i].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "i=%d SKYPIAX_INTERFACES[%d].context=%s\n", i, i,
+ SKYPIAX_INTERFACES[i].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "i=%d SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i,
+ SKYPIAX_INTERFACES[i].dialplan);
+ }
+ }
+ }
+
+ switch_xml_free(xml);
+
+ return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
struct skypiax_interface *p = NULL;
- module_pool = pool;
+ module_pool = pool;
- memset(&globals, '\0', sizeof(globals));
- memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
+ memset(&globals, '\0', sizeof(globals));
+ memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
-#ifndef _WINDOWS_ //FIXME
+#ifndef _WINDOWS_ //FIXME
if (!XInitThreads()) {
- ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
+ ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
} else {
- DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
}
-switch_sleep(10000); //FIXME
+ switch_sleep(10000); //FIXME
#endif /* _WINDOWS_ */
+ load_config();
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ skypiax_endpoint_interface =
+ switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
+ skypiax_endpoint_interface->interface_name = "skypiax";
+ skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
+ skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
- load_config();
-
-
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
- skypiax_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
- skypiax_endpoint_interface->interface_name = "skypiax";
- skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
- skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
-
- /* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
}
/*
@@ -3094,64 +3124,64 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
{
- int x = 0;
+ int x = 0;
+
+ running = -1;
+
+ while (running) {
+ if (x++ > 100) {
+ break;
+ }
+ switch_yield(20000);
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+static switch_status_t channel_on_hangup(switch_core_session_t * session)
+{
+ switch_channel_t *channel = NULL;
+ private_t *tech_pvt = NULL;
+ skypiax_interface_t *p;
+ char msg_to_skype[256];
- running = -1;
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
- while (running) {
- if (x++ > 100) {
- break;
- }
- switch_yield(20000);
- }
- return SWITCH_STATUS_SUCCESS;
-}
-
-static switch_status_t channel_on_hangup(switch_core_session_t *session)
-{
- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- skypiax_interface_t *p;
- char msg_to_skype[256];
-
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
-
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
-
- p = tech_pvt->p;
-
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
-
- if(strlen(p->skype_call_id)) {
- //switch_thread_cond_signal(tech_pvt->cond);
- WARNINGA("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);
- }
-
- if (tech_pvt->read_codec.implementation) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
- }
-
- if (tech_pvt->write_codec.implementation) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
- }
-
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel));
- switch_mutex_lock(globals.mutex);
- globals.calls--;
- if (globals.calls < 0) {
- globals.calls = 0;
- }
- switch_mutex_unlock(globals.mutex);
+ tech_pvt = switch_core_session_get_private(session);
+ assert(tech_pvt != NULL);
- return SWITCH_STATUS_SUCCESS;
+ p = tech_pvt->p;
+
+ switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+ switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+ //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+
+ if (strlen(p->skype_call_id)) {
+ //switch_thread_cond_signal(tech_pvt->cond);
+ WARNINGA("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);
+ }
+
+ if (tech_pvt->read_codec.implementation) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ }
+
+ if (tech_pvt->write_codec.implementation) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n",
+ switch_channel_get_name(channel));
+ switch_mutex_lock(globals.mutex);
+ globals.calls--;
+ if (globals.calls < 0) {
+ globals.calls = 0;
+ }
+ switch_mutex_unlock(globals.mutex);
+
+ return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:
1
0
[commit] r10607 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 05 Dec '08
by FreeSWITCH SVN 05 Dec '08
05 Dec '08
Author: gmaruzz
Date: Fri Dec 5 00:58:44 2008
New Revision: 10607
Log:
skypiax: compile clean on linux
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Fri Dec 5 00:58:44 2008
@@ -34,8 +34,8 @@
*
*/
-#define WIN32_SKYPIAX
-#define __CYGWIN__
+#undef WIN32_SKYPIAX
+#undef __CYGWIN__
#define MOD_SKYPIAX
#ifdef MOD_SKYPIAX
@@ -689,7 +689,6 @@
int i;
unsigned int kill_cli_size;
short kill_cli_buff[320];
- private_t *tech_pvt;
if (option_debug > 10) {
WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
1
0