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
- 12151 discussions
Author: anthm
Date: Mon Feb 9 18:58:54 2009
New Revision: 11723
Log:
FSCORE-288
Modified:
freeswitch/trunk/src/include/switch_resample.h
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_ivr_async.c
freeswitch/trunk/src/switch_resample.c
Modified: freeswitch/trunk/src/include/switch_resample.h
==============================================================================
--- freeswitch/trunk/src/include/switch_resample.h (original)
+++ freeswitch/trunk/src/include/switch_resample.h Mon Feb 9 18:58:54 2009
@@ -85,8 +85,11 @@
\param pool the memory pool to use for buffer allocation
\return SWITCH_STATUS_SUCCESS if the handle was created
*/
-SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t **new_resampler,
- int from_rate, switch_size_t from_size, int to_rate, uint32_t to_size, switch_memory_pool_t *pool);
+SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler,
+ int from_rate, switch_size_t from_size, int to_rate,
+ uint32_t to_size, switch_memory_pool_t *pool, const char *file, const char *func, int line);
+
+#define switch_resample_create(_n, _fr, _fs, _tr, _ts, _p) switch_resample_perform_create(_n, _fr, _fs, _tr, _ts, _p, __FILE__, __SWITCH_FUNC__, __LINE__)
/*!
\brief Destroy an existing resampler handle
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Mon Feb 9 18:58:54 2009
@@ -568,7 +568,8 @@
switch_status_t status = SWITCH_STATUS_FALSE;
switch_frame_t *enc_frame = NULL, *write_frame = frame;
unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0, do_resample = 0, ptime_mismatch = 0, pass_cng = 0, resample = 0;
-
+ int did_write_resample = 0;
+
switch_assert(session != NULL);
switch_assert(frame != NULL);
@@ -665,7 +666,7 @@
session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
-
+
if (do_resample && status == SWITCH_STATUS_SUCCESS) {
status = SWITCH_STATUS_RESAMPLE;
@@ -675,6 +676,7 @@
case SWITCH_STATUS_RESAMPLE:
resample++;
write_frame = &session->raw_write_frame;
+ write_frame->rate = frame->codec->implementation->actual_samples_per_second;
if (!session->write_resampler) {
switch_mutex_lock(session->resample_mutex);
status = switch_resample_create(&session->write_resampler,
@@ -729,7 +731,6 @@
short *data = write_frame->data;
switch_mutex_lock(session->resample_mutex);
-
session->write_resampler->from_len = write_frame->datalen / 2;
switch_short_to_float(data, session->write_resampler->from, session->write_resampler->from_len);
@@ -742,12 +743,13 @@
write_frame->samples = session->write_resampler->to_len;
write_frame->datalen = write_frame->samples * 2;
write_frame->rate = session->write_resampler->to_rate;
+ did_write_resample = 1;
switch_mutex_unlock(session->resample_mutex);
}
if (session->bugs && !switch_channel_test_flag(session->channel, CF_PAUSE_BUGS)) {
switch_media_bug_t *bp, *dp, *last = NULL;
-
+
switch_thread_rwlock_rdlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) {
switch_bool_t ok = SWITCH_TRUE;
@@ -813,7 +815,7 @@
}
if (perfect) {
-
+
if (write_frame->datalen < session->write_impl.decoded_bytes_per_packet) {
memset(write_frame->data, 255, session->write_impl.decoded_bytes_per_packet - write_frame->datalen);
write_frame->datalen = session->write_impl.decoded_bytes_per_packet;
@@ -890,7 +892,7 @@
goto error;
}
}
-
+
if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
status = SWITCH_STATUS_MEMERR; goto error;
@@ -912,20 +914,25 @@
enc_frame = &session->raw_write_frame;
session->raw_write_frame.rate = session->write_impl.actual_samples_per_second;
session->enc_write_frame.datalen = session->enc_write_frame.buflen;
+
+
if (frame->codec && frame->codec->implementation) {
rate = frame->codec->implementation->actual_samples_per_second;
} else {
rate = session->write_impl.actual_samples_per_second;
}
-
+
status = switch_core_codec_encode(session->write_codec,
frame->codec,
enc_frame->data,
enc_frame->datalen,
rate,
session->enc_write_frame.data,
- &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
+ &session->enc_write_frame.datalen,
+ &session->enc_write_frame.rate, &flag);
+
+
switch (status) {
case SWITCH_STATUS_RESAMPLE:
resample++;
@@ -983,7 +990,7 @@
goto error;
}
- if (session->read_resampler) {
+ if (!did_write_resample && session->read_resampler) {
short *data = write_frame->data;
switch_mutex_lock(session->resample_mutex);
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Mon Feb 9 18:58:54 2009
@@ -556,7 +556,6 @@
switch_core_session_t *tsession;
switch_status_t status = SWITCH_STATUS_FALSE;
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
int codec_initialized = 0;
if ((tsession = switch_core_session_locate(uuid))) {
@@ -566,11 +565,12 @@
switch_frame_t *read_frame, write_frame = { 0 };
switch_codec_t codec = { 0 };
int16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE / 2];
- switch_codec_t *tread_codec = switch_core_session_get_read_codec(tsession);
uint32_t tlen;
const char *macro_name = "eavesdrop_announce";
const char *id_name = NULL;
+ switch_codec_implementation_t tread_impl = {0}, read_impl = {0};
+
if (!switch_channel_media_ready(channel)) {
goto end;
}
@@ -579,6 +579,9 @@
goto end;
}
+ switch_core_session_get_read_impl(tsession, &tread_impl);
+ switch_core_session_get_read_impl(session, &read_impl);
+
if ((id_name = switch_channel_get_variable(tchannel, "eavesdrop_announce_id"))) {
const char *tmp = switch_channel_get_variable(tchannel, "eavesdrop_annnounce_macro");
if (tmp) {
@@ -622,16 +625,16 @@
ep = switch_core_session_alloc(session, sizeof(*ep));
- tlen = tread_codec->implementation->decoded_bytes_per_packet;
+ tlen = tread_impl.decoded_bytes_per_packet;
switch_channel_pre_answer(channel);
if (switch_core_codec_init(&codec,
"L16",
NULL,
- tread_codec->implementation->actual_samples_per_second,
- tread_codec->implementation->microseconds_per_packet / 1000,
- tread_codec->implementation->number_of_channels,
+ tread_impl.actual_samples_per_second,
+ tread_impl.microseconds_per_packet / 1000,
+ tread_impl.number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot init codec\n");
@@ -645,7 +648,7 @@
write_frame.codec = &codec;
write_frame.data = buf;
write_frame.buflen = sizeof(buf);
- write_frame.rate = read_codec->implementation->actual_samples_per_second;
+ write_frame.rate = codec.implementation->actual_samples_per_second;
ep->flags = flags;
switch_mutex_init(&ep->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(tsession));
@@ -731,7 +734,7 @@
switch_buffer_zero(ep->r_buffer);
switch_buffer_unlock(ep->r_buffer);
}
-
+
if (ep->w_buffer) {
switch_buffer_lock(ep->w_buffer);
switch_buffer_zero(ep->w_buffer);
@@ -760,6 +763,7 @@
while (switch_buffer_inuse(ep->buffer) >= len) {
write_frame.datalen = (uint32_t) switch_buffer_read(ep->buffer, buf, len);
write_frame.samples = write_frame.datalen / 2;
+
if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
break;
}
Modified: freeswitch/trunk/src/switch_resample.c
==============================================================================
--- freeswitch/trunk/src/switch_resample.c (original)
+++ freeswitch/trunk/src/switch_resample.c Mon Feb 9 18:58:54 2009
@@ -53,8 +53,9 @@
#define resample_buffer(a, b, c) a > b ? ((a / 1000) / 2) * c : ((b / 1000) / 2) * c
-SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t **new_resampler,
- int from_rate, switch_size_t from_size, int to_rate, uint32_t to_size, switch_memory_pool_t *pool)
+SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler,
+ int from_rate, switch_size_t from_size, int to_rate,
+ uint32_t to_size, switch_memory_pool_t *pool, const char *file, const char *func, int line)
{
#ifdef DISABLE_RESAMPLE
*new_resampler = NULL;
@@ -75,8 +76,8 @@
resampler->rfactor = (lfrom_rate / lto_rate);
resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,
- resampler->factor);
+ switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE,
+ "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate, resampler->factor);
resampler->from_size = resample_buffer(to_rate, from_rate, (uint32_t) from_size);
resampler->from = (float *) switch_core_alloc(pool, resampler->from_size * sizeof(float));
resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);;
1
0
09 Feb '09
Author: mikej
Date: Mon Feb 9 16:35:54 2009
New Revision: 11722
Log:
use sofia specific flag macros
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 Mon Feb 9 16:35:54 2009
@@ -441,7 +441,7 @@
}
} else {
/* This if statement check and handles the 3pcc proxy mode */
- if ((tech_pvt->profile->pflags & PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
+ if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
/* Send the 200 OK */
nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
@@ -1926,7 +1926,7 @@
}
}
- stream->write_function(stream, "+OK stun-auto-disable=%s", (profile->pflags & PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
+ stream->write_function(stream, "+OK stun-auto-disable=%s", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
goto done;
}
@@ -1941,7 +1941,7 @@
}
}
- stream->write_function(stream, "+OK stun-enabled=%s", (profile->pflags & PFLAG_STUN_ENABLED) ? "true" : "false");
+ stream->write_function(stream, "+OK stun-enabled=%s", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
goto done;
}
1
0
Author: brian
Date: Mon Feb 9 15:28:38 2009
New Revision: 11721
Log:
FSCORE-289
Modified:
freeswitch/trunk/src/switch_rtp.c
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Mon Feb 9 15:28:38 2009
@@ -1645,11 +1645,13 @@
}
rtp_session->dtmf_data.last_duration = duration;
-#ifdef DEBUG_2833
} else {
+#ifdef DEBUG_2833
printf("drop: %c %u %u %u %u %d %d\n",
key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq, ts, duration, rtp_session->recv_msg.header.m, end);
#endif
+ switch_cond_next();
+ goto recvfrom;
}
}
1
0
09 Feb '09
Author: moy
Date: Mon Feb 9 14:32:26 2009
New Revision: 11720
Log:
fixing zap device name and adding error message for a failed open in mod_dahdi_codec
Modified:
freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c
Modified: freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c Mon Feb 9 14:32:26 2009
@@ -345,7 +345,7 @@
if (!stat(transcoding_device_dahdi, &statbuf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "DAHDI transcoding device found.\n");
transcoding_device = transcoding_device_dahdi;
- transcoder_name = transcoder_name_zap;
+ transcoder_name = transcoder_name_dahdi;
} else if (!stat(transcoding_device_zap, &statbuf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Zap transcoding device found.\n");
transcoding_device = transcoding_device_zap;
@@ -357,7 +357,8 @@
fd = open(transcoding_device, O_RDWR);
if (fd < 0) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device.\n", transcoder_name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n",
+ transcoder_name, strerror(errno));
return SWITCH_STATUS_FALSE;
}
1
0
Author: gmaruzz
Date: Mon Feb 9 13:25:18 2009
New Revision: 11719
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 13:25:18 2009
@@ -1058,13 +1058,16 @@
if (channel) {
switch_dtmf_t dtmf =
{ (char) value[0], switch_core_default_dtmf_duration(0) };
- DEBUGA_SKYPE("%c DTMF %s\n", SKYPIAX_P_LOG, dtmf.digit,
+ NOTICA("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
switch_channel_get_name(channel));
switch_mutex_lock(tech_pvt->flag_mutex);
+ //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
switch_channel_queue_dtmf(channel, &dtmf);
switch_set_flag(tech_pvt, TFLAG_DTMF);
switch_mutex_unlock(tech_pvt->flag_mutex);
- }
+ } else {
+ WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]);
+ }
switch_core_session_rwunlock(session);
return 0;
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 13:25:18 2009
@@ -23,309 +23,8 @@
#endif /* WIN32 */
/*************************************/
-void *skypiax_do_tcp_srv_thread_func(void *obj)
-{
- private_t *tech_pvt = obj;
- int s;
- unsigned int len;
- unsigned int i;
- unsigned int a;
-#if defined(WIN32) && !defined(__CYGWIN__)
- int sin_size;
-#else /* WIN32 */
- unsigned int sin_size;
-#endif /* WIN32 */
- unsigned int fd;
- short srv_in[SAMPLES_PER_FRAME];
- short srv_out[SAMPLES_PER_FRAME / 2];
- struct sockaddr_in my_addr;
- struct sockaddr_in remote_addr;
- int exit = 0;
- unsigned int kill_cli_size;
- short kill_cli_buff[SAMPLES_PER_FRAME];
- short totalbuf[SAMPLES_PER_FRAME];
-
- memset(&my_addr, 0, sizeof(my_addr));
- my_addr.sin_family = AF_INET;
- my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- ERRORA("socket Error\n", SKYPIAX_P_LOG);
- return NULL;
- }
-
- if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
- ERRORA("bind Error\n", SKYPIAX_P_LOG);
- return NULL;
- }
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
- listen(s, 6);
-
- sin_size = sizeof(remote_addr);
- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- if (!running)
- break;
- while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
- && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
-
- unsigned int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- if (!running)
- break;
- exit = 1;
-
- fdselect = fd;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //2000 msec
- to.tv_sec = 0;
-
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- if (rt > 0) {
-
- len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
-
- if (len == 320) {
- unsigned int howmany;
-
- if (SAMPLERATE_SKYPIAX == 8000) {
- /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
- a = 0;
- for (i = 0; i < len / sizeof(short); i++) {
- srv_out[a] = srv_in[i];
- i++;
- a++;
- }
- } else if (SAMPLERATE_SKYPIAX == 16000) {
- /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
- for (i = 0; i < len / sizeof(short); i++) {
- srv_out[i] = srv_in[i];
- }
- } else {
- ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
- }
- /* if not yet done, let's store the half incoming frame */
- if (!tech_pvt->audiobuf_is_loaded) {
- for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
- tech_pvt->audiobuf[i] = srv_out[i];
- }
- tech_pvt->audiobuf_is_loaded = 1;
- } else {
- /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
- for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
- totalbuf[i] = tech_pvt->audiobuf[i];
- }
- for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
- totalbuf[i] = srv_out[a];
- i++;
- }
- /* send the complete frame through the pipe to our code waiting for incoming audio */
- howmany =
- skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
- SAMPLES_PER_FRAME * sizeof(short));
- if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
- ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany,
- SAMPLES_PER_FRAME * sizeof(short));
- }
- /* done with the stored half frame */
- tech_pvt->audiobuf_is_loaded = 0;
- }
-
- } else if (len == 0) {
- DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
- skypiax_sleep(1000);
- } else {
- ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
- exit = 1;
- break;
- }
-
- } else {
- if (rt)
- ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
- skypiax_sleep(10000);
- }
-
- }
-
- /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
- kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
- len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
-
- DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(fd);
- if (exit)
- break;
- }
-
- DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(s);
- return NULL;
-}
-
-void *skypiax_do_tcp_cli_thread_func(void *obj)
-{
- private_t *tech_pvt = obj;
- int s;
- struct sockaddr_in my_addr;
- struct sockaddr_in remote_addr;
- unsigned int got;
- unsigned int len;
- unsigned int i;
- unsigned int a;
- unsigned int fd;
- short cli_out[SAMPLES_PER_FRAME * 2];
- short cli_in[SAMPLES_PER_FRAME];
-#ifdef WIN32
- int sin_size;
-#else
- unsigned int sin_size;
-#endif /* WIN32 */
-
- memset(&my_addr, 0, sizeof(my_addr));
- my_addr.sin_family = AF_INET;
- my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(tech_pvt->tcp_cli_port);
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- ERRORA("socket Error\n", SKYPIAX_P_LOG);
- return NULL;
- }
-
- if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
- ERRORA("bind Error\n", SKYPIAX_P_LOG);
- skypiax_close_socket(s);
- return NULL;
- }
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-
- listen(s, 6);
-
- sin_size = sizeof(remote_addr);
- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- if (!running)
- break;
- while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
- && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
- unsigned int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- if (!running)
- break;
- fdselect = fd;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //2000 msec
- to.tv_sec = 0;
-
- rt = select(fdselect + 1, NULL, &fs, NULL, &to);
-
- if (rt > 0) {
-
- /* read from the pipe the audio frame we are supposed to send out */
- got =
- skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
- SAMPLES_PER_FRAME * sizeof(short));
- if (got != SAMPLES_PER_FRAME * sizeof(short)) {
- WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- SAMPLES_PER_FRAME * sizeof(short));
- }
-
- if (got == SAMPLES_PER_FRAME * sizeof(short)) {
- if (SAMPLERATE_SKYPIAX == 8000) {
-
- /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
- a = 0;
- for (i = 0; i < got / sizeof(short); i++) {
- cli_out[a] = cli_in[i];
- a++;
- cli_out[a] = cli_in[i];
- a++;
- }
- got = got * 2;
- } else if (SAMPLERATE_SKYPIAX == 16000) {
- /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
- for (i = 0; i < got / sizeof(short); i++) {
- cli_out[i] = cli_in[i];
- }
- } else {
- ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
- }
-
- /* send the 16khz frame to the Skype client waiting for incoming audio */
- len = send(fd, (char *) cli_out, got, 0);
-
- if (len == -1) {
- break;
- } else if (len != got) {
- ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
- skypiax_sleep(1000);
- break;
- }
-
- } else {
-
- WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- SAMPLES_PER_FRAME * sizeof(short));
- }
- } else {
- if (rt)
- ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
- skypiax_sleep(10000);
- }
-
- }
- DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(fd);
- break;
- }
-
- DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG);
- skypiax_close_socket(s);
- return NULL;
-}
-
-int skypiax_skypeaudio_read(private_t * tech_pvt)
-{
- unsigned int samples;
-
- samples =
- skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data,
- SAMPLES_PER_FRAME * sizeof(short));
-
- if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
- if (samples)
- WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples,
- SAMPLES_PER_FRAME * sizeof(short));
- return 0;
- } else {
- /* A real frame */
- tech_pvt->read_frame.datalen = samples;
- }
- return 1;
-}
-
int skypiax_skype_read(private_t * tech_pvt)
{
-
char read_from_pipe[4096];
char message[4096];
char message_2[4096];
@@ -361,9 +60,8 @@
skypiax_sleep(10000);
return 0;
}
-
if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
- ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n",
SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
@@ -376,9 +74,7 @@
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
}
}
-
strncpy(message_2, message, sizeof(message) - 1);
-
buf = message;
stringp = &buf;
where = strsep(stringp, " ");
@@ -386,7 +82,7 @@
WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
}
if (!strcasecmp(message, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
+ WARNINGA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@@ -400,11 +96,8 @@
}
if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
strncpy(obj, where, sizeof(obj) - 1);
-
where = strsep(stringp, " ");
-
strncpy(id, where, sizeof(id) - 1);
-
if (!strcasecmp(id, tech_pvt->skype_user)) {
tech_pvt->SkypiaxHandles.api_connected = 1;
DEBUGA_SKYPE
@@ -412,309 +105,557 @@
SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
}
}
-
if (!strcasecmp(message, "USER")) {
strncpy(obj, where, sizeof(obj) - 1);
-
where = strsep(stringp, " ");
-
strncpy(id, where, sizeof(id) - 1);
-
where = strsep(stringp, " ");
+ strncpy(prop, where, sizeof(prop) - 1);
+ if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
+ //TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ }
+ if (!strcasecmp(message, "MESSAGE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
+ where = strsep(stringp, " ");
+ strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
+ strncpy(prop, where, sizeof(prop) - 1);
+ if (!strcasecmp(prop, "STATUS")) {
+ where = strsep(stringp, " ");
+ strncpy(value, where, sizeof(value) - 1);
+ if (!strcasecmp(value, "RECEIVED")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value);
+ //TODO: authomatically flag messages as read based on config param
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ } else if (!strcasecmp(prop, "BODY")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
+ //TODO: authomatically flag messages as read based on config param
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ }
+ if (!strcasecmp(message, "CALL")) {
+ strncpy(obj, where, sizeof(obj) - 1);
+ where = strsep(stringp, " ");
+ strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
+ strncpy(prop, where, sizeof(prop) - 1);
+ where = strsep(stringp, " ");
+ strncpy(value, where, sizeof(value) - 1);
+ where = strsep(stringp, " ");
+
+ DEBUGA_SKYPE
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
+
+ if (!strcasecmp(prop, "PARTNER_HANDLE")) {
+ strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1);
+ DEBUGA_SKYPE
+ ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
+ SKYPIAX_P_LOG, id, tech_pvt->callid_number);
+ return CALLFLOW_INCOMING_RING;
+ }
+ if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
+ snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
+ value, where ? " " : "", where ? where : "");
+ DEBUGA_SKYPE
+ ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
+ SKYPIAX_P_LOG, id, tech_pvt->callid_name);
+ }
+ if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
+ if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
+ if (!strcasecmp(prop, "DTMF")) {
+ NOTICA("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+ dtmf_received(tech_pvt, value);
+ }
+ if (!strcasecmp(prop, "FAILUREREASON")) {
+ DEBUGA_SKYPE
+ ("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
+ if (strcasecmp(id, tech_pvt->skype_call_id)) {
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ }
+ if (!strcasecmp(prop, "STATUS")) {
+
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
+ /* we are not calling out */
+ if (!strlen(tech_pvt->skype_call_id)) {
+ /* we are not inside an active call */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RING;
+ /* no owner, no active call, let's answer */
+ skypiax_skype_write(tech_pvt, "SET AGC OFF");
+ skypiax_sleep(10000);
+ skypiax_skype_write(tech_pvt, "SET AEC OFF");
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
+ id);
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ } else {
+ /* we're owned, we're in a call, let's refuse */
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ DEBUGA_SKYPE
+ ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
+ SKYPIAX_P_LOG, id);
+ }
+ } else {
+ /* we are calling out */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
+ SKYPIAX_P_LOG, id);
+ }
+ } else if (!strcasecmp(value, "EARLYMEDIA")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
+ SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "FINISHED")) {
+ DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ } else if (!strcasecmp(value, "CANCELLED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ } else if (!strcasecmp(value, "FAILED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
+ SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else if (!strcasecmp(value, "REFUSED")) {
+ if (!strcasecmp(id, tech_pvt->skype_call_id)) {
+ /* this is the id of the call we are in, probably we generated it */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ SKYPIAX_P_LOG, id);
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ tech_pvt->skype_call_id[0] = '\0';
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ /* we're here because were us that refused an incoming call */
+ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
+ }
+ } else if (!strcasecmp(value, "ROUTING")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "UNPLACED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "INPROGRESS")) {
+ char msg_to_skype[1024];
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_UP;
+ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_cli_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ start_audio_threads(tech_pvt);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_srv_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+ if (!strlen(tech_pvt->session_uuid_str)) {
+ DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
+ new_inbound_channel(tech_pvt);
+ } else {
+ DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
+ outbound_channel_answered(tech_pvt);
+ }
+ } else {
+ WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
+ value);
+ }
+ } //STATUS
+ } //CALL
+ /* the "numbered" messages that follows are used by the directory application, not yet ported */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
+ memset(tech_pvt->skype_friends, 0, 4096);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
+ }
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_fullname, 0, 512);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
+ }
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_displayname, 0, 512);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
+ }
+ a = 0;
+ } //message end
+ } //read_from_pipe
+ return 0;
+}
- strncpy(prop, where, sizeof(prop) - 1);
+void *skypiax_do_tcp_srv_thread_func(void *obj)
+{
+ private_t *tech_pvt = obj;
+ int s;
+ unsigned int len;
+ unsigned int i;
+ unsigned int a;
+#if defined(WIN32) && !defined(__CYGWIN__)
+ int sin_size;
+#else /* WIN32 */
+ unsigned int sin_size;
+#endif /* WIN32 */
+ unsigned int fd;
+ short srv_in[SAMPLES_PER_FRAME];
+ short srv_out[SAMPLES_PER_FRAME / 2];
+ struct sockaddr_in my_addr;
+ struct sockaddr_in remote_addr;
+ int exit = 0;
+ unsigned int kill_cli_size;
+ short kill_cli_buff[SAMPLES_PER_FRAME];
+ short totalbuf[SAMPLES_PER_FRAME];
- if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop);
+ memset(&my_addr, 0, sizeof(my_addr));
+ my_addr.sin_family = AF_INET;
+ my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
+ my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
- }
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ ERRORA("socket Error\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
- if (!strcasecmp(message, "MESSAGE")) {
- strncpy(obj, where, sizeof(obj) - 1);
+ if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
+ ERRORA("bind Error\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
- where = strsep(stringp, " ");
+ listen(s, 6);
- strncpy(id, where, sizeof(id) - 1);
+ sin_size = sizeof(remote_addr);
+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+ if (!running)
+ break;
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
- where = strsep(stringp, " ");
+ unsigned int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
- strncpy(prop, where, sizeof(prop) - 1);
+ if (!running)
+ break;
+ exit = 1;
- if (!strcasecmp(prop, "STATUS")) {
+ fdselect = fd;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 2000000; //2000 msec
+ to.tv_sec = 0;
- where = strsep(stringp, " ");
+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
- strncpy(value, where, sizeof(value) - 1);
+ len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
- if (!strcasecmp(value, "RECEIVED")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop, value);
+ if (len == 320) {
+ unsigned int howmany;
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ if (SAMPLERATE_SKYPIAX == 8000) {
+ /* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
+ a = 0;
+ for (i = 0; i < len / sizeof(short); i++) {
+ srv_out[a] = srv_in[i];
+ i++;
+ a++;
+ }
+ } else if (SAMPLERATE_SKYPIAX == 16000) {
+ /* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
+ for (i = 0; i < len / sizeof(short); i++) {
+ srv_out[i] = srv_in[i];
+ }
+ } else {
+ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+ }
+ /* if not yet done, let's store the half incoming frame */
+ if (!tech_pvt->audiobuf_is_loaded) {
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
+ tech_pvt->audiobuf[i] = srv_out[i];
+ }
+ tech_pvt->audiobuf_is_loaded = 1;
+ } else {
+ /* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
+ for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
+ totalbuf[i] = tech_pvt->audiobuf[i];
+ }
+ for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
+ totalbuf[i] = srv_out[a];
+ i++;
+ }
+ /* send the complete frame through the pipe to our code waiting for incoming audio */
+ howmany =
+ skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
+ SAMPLES_PER_FRAME * sizeof(short));
+ if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
+ ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany,
+ SAMPLES_PER_FRAME * sizeof(short));
+ }
+ /* done with the stored half frame */
+ tech_pvt->audiobuf_is_loaded = 0;
}
- } else if (!strcasecmp(prop, "BODY")) {
- char msg_to_skype[256];
-
- DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop);
- //FIXME: TODO: on config param ???
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ } else if (len == 0) {
+ DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
+ skypiax_sleep(1000);
+ } else {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ exit = 1;
+ break;
}
+ } else {
+ if (rt)
+ ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
+ skypiax_sleep(10000);
}
- if (!strcasecmp(message, "CALL")) {
-
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(id, where, sizeof(id) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(prop, where, sizeof(prop) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(value, where, sizeof(value) - 1);
-
- where = strsep(stringp, " ");
-
- DEBUGA_SKYPE
- ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
-
- if (!strcasecmp(prop, "PARTNER_HANDLE")) {
- strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1);
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_number);
- return CALLFLOW_INCOMING_RING;
- }
- if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
- snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
- value, where ? " " : "", where ? where : "");
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_name);
- }
- if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
- if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
+ }
- if (!strcasecmp(prop, "DTMF")) {
+ /* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
+ len = skypiax_pipe_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
- DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+ DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(fd);
+ if (exit)
+ break;
+ }
- dtmf_received(tech_pvt, value);
- }
+ DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(s);
+ return NULL;
+}
- if (!strcasecmp(prop, "FAILUREREASON")) {
- DEBUGA_SKYPE
- ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
- SKYPIAX_P_LOG, id);
- }
- if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
- if (strcasecmp(id, tech_pvt->skype_call_id)) {
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE
- ("We called a Skype contact and he answered us on skype_call: %s.\n",
- SKYPIAX_P_LOG, id);
- }
- }
+void *skypiax_do_tcp_cli_thread_func(void *obj)
+{
+ private_t *tech_pvt = obj;
+ int s;
+ struct sockaddr_in my_addr;
+ struct sockaddr_in remote_addr;
+ unsigned int got;
+ unsigned int len;
+ unsigned int i;
+ unsigned int a;
+ unsigned int fd;
+ short cli_out[SAMPLES_PER_FRAME * 2];
+ short cli_in[SAMPLES_PER_FRAME];
+#ifdef WIN32
+ int sin_size;
+#else
+ unsigned int sin_size;
+#endif /* WIN32 */
- if (!strcasecmp(prop, "STATUS")) {
+ memset(&my_addr, 0, sizeof(my_addr));
+ my_addr.sin_family = AF_INET;
+ my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
+ my_addr.sin_port = htons(tech_pvt->tcp_cli_port);
- if (!strcasecmp(value, "RINGING")) {
- char msg_to_skype[1024];
- if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ ERRORA("socket Error\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
- if (!strlen(tech_pvt->skype_call_id)) { //FIXME
- /* we are not inside an active call */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- /* no owner, no active call, let's answer */
- skypiax_skype_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_skype_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
- id);
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- } else {
- /* we're owned, we're in a call, let's refuse */
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- DEBUGA_SKYPE
- ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
- SKYPIAX_P_LOG, id);
+ if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
+ ERRORA("bind Error\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(s);
+ return NULL;
+ }
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
- } else {
- /* we are calling out */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
- SKYPIAX_P_LOG, id);
- }
- } else if (!strcasecmp(value, "EARLYMEDIA")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
- SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "MISSED")) {
- DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
+ listen(s, 6);
- } else if (!strcasecmp(value, "FINISHED")) {
- //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
+ sin_size = sizeof(remote_addr);
+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+ if (!running)
+ break;
+ while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+ && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
+ unsigned int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
+ if (!running)
+ break;
+ fdselect = fd;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 2000000; //2000 msec
+ to.tv_sec = 0;
- } else if (!strcasecmp(value, "CANCELLED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
- SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
+ rt = select(fdselect + 1, NULL, &fs, NULL, &to);
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- } else if (!strcasecmp(value, "FAILED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
- SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else if (!strcasecmp(value, "REFUSED")) {
- if (!strcasecmp(id, tech_pvt->skype_call_id)) {
- /* this is the id of the call we are in, probably we generated it */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
- SKYPIAX_P_LOG, id);
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- tech_pvt->skype_call_id[0] = '\0';
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- /* we're here because were us that refused an incoming call */
- DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
+ if (rt > 0) {
- }
- } else if (!strcasecmp(value, "ROUTING")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "UNPLACED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "INPROGRESS")) {
- char msg_to_skype[1024];
- tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_UP;
- DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
- tech_pvt->tcp_cli_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- start_audio_threads(tech_pvt);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
- tech_pvt->tcp_srv_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ /* read from the pipe the audio frame we are supposed to send out */
+ got =
+ skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
+ SAMPLES_PER_FRAME * sizeof(short));
+ if (got != SAMPLES_PER_FRAME * sizeof(short)) {
+ WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+ SAMPLES_PER_FRAME * sizeof(short));
+ }
- tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+ if (got == SAMPLES_PER_FRAME * sizeof(short)) {
+ if (SAMPLERATE_SKYPIAX == 8000) {
- if (!strlen(tech_pvt->session_uuid_str)) {
- DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
- new_inbound_channel(tech_pvt);
- } else {
- DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
- outbound_channel_answered(tech_pvt);
+ /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
+ a = 0;
+ for (i = 0; i < got / sizeof(short); i++) {
+ cli_out[a] = cli_in[i];
+ a++;
+ cli_out[a] = cli_in[i];
+ a++;
+ }
+ got = got * 2;
+ } else if (SAMPLERATE_SKYPIAX == 16000) {
+ /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
+ for (i = 0; i < got / sizeof(short); i++) {
+ cli_out[i] = cli_in[i];
}
-
} else {
- WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
- value);
+ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+ }
+ /* send the 16khz frame to the Skype client waiting for incoming audio */
+ len = send(fd, (char *) cli_out, got, 0);
+
+ if (len == -1) {
+ break;
+ } else if (len != got) {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ skypiax_sleep(1000);
+ break;
}
- } //STATUS
- } //CALL
+ } else {
- /* the "numbered" messages that follows are used by the directory application, not yet ported */
- if (!strcasecmp(message, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[11]); */
- memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
- }
- if (!strcasecmp(message, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
- }
- if (!strcasecmp(message, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
+ WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+ SAMPLES_PER_FRAME * sizeof(short));
+ }
+ } else {
+ if (rt)
+ ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
+ skypiax_sleep(10000);
}
- a = 0;
- } //message end
- } //read_from_pipe
+ }
+ DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(fd);
+ break;
+ }
- return 0;
+ DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG);
+ skypiax_close_socket(s);
+ return NULL;
+}
+
+int skypiax_skypeaudio_read(private_t * tech_pvt)
+{
+ unsigned int samples;
+
+ samples =
+ skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data,
+ SAMPLES_PER_FRAME * sizeof(short));
+
+ if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samples)
+ WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples,
+ SAMPLES_PER_FRAME * sizeof(short));
+ return 0;
+ } else {
+ /* A real frame */
+ tech_pvt->read_frame.datalen = samples;
+ }
+ return 1;
}
int skypiax_skype_senddigit(private_t * tech_pvt, char digit)
@@ -722,9 +663,7 @@
char msg_to_skype[1024];
DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
-
sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
-
skypiax_skype_write(tech_pvt, msg_to_skype);
return 0;
@@ -743,7 +682,6 @@
sprintf(msg_to_skype, "CALL %s", rdest);
if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {
-
ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
return -1;
}
1
0
Author: brian
Date: Mon Feb 9 13:14:34 2009
New Revision: 11718
Log:
avoid polycom bug
Modified:
freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c
Modified: freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c Mon Feb 9 13:14:34 2009
@@ -173,7 +173,7 @@
switch_core_codec_add_implementation(pool,
codec_interface,
SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
- 114, /* the IANA code number */
+ 115, /* the IANA code number */
"G7221", /* the IANA code name */
"bitrate=48000", /* default fmtp to send (can be overridden by the init function) */
32000, /* samples transferred per second */
1
0
Author: mrene
Date: Mon Feb 9 12:48:26 2009
New Revision: 11717
Log:
Add commented disable-srv and disable-naptr options to sample config
Modified:
freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml
freeswitch/trunk/conf/sip_profiles/internal.xml
Modified: freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/internal-ipv6.xml Mon Feb 9 12:48:26 2009
@@ -119,6 +119,10 @@
<!-- set to true to have the profile determine stun is not useful and turn it off globally-->
<!--<param name="stun-auto-disable" value="true"/>-->
+ <!-- the following can be used as workaround with bogus SRV/NAPTR records -->
+ <!--<param name="disable-srv" value="false" />-->
+ <!--<param name="disable-naptr" value="false" />-->
+
</settings>
</profile>
Modified: freeswitch/trunk/conf/sip_profiles/internal.xml
==============================================================================
--- freeswitch/trunk/conf/sip_profiles/internal.xml (original)
+++ freeswitch/trunk/conf/sip_profiles/internal.xml Mon Feb 9 12:48:26 2009
@@ -197,6 +197,11 @@
-->
<!--<param name="auto-rtp-bugs" data="clear"/>-->
+
+ <!-- the following can be used as workaround with bogus SRV/NAPTR records -->
+ <!--<param name="disable-srv" value="false" />-->
+ <!--<param name="disable-naptr" value="false" />-->
+
</settings>
</profile>
1
0
Author: gmaruzz
Date: Mon Feb 9 12:26:48 2009
New Revision: 11716
Log:
skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:26:48 2009
@@ -339,387 +339,380 @@
memset(message, 0, 4096);
memset(message_2, 0, 4096);
- howmany =
- skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
- sizeof(read_from_pipe));
-
- a = 0;
- for (i = 0; i < howmany; i++) {
- message[a] = read_from_pipe[i];
- a++;
-
- if (read_from_pipe[i] == '\0') {
+ howmany =
+ skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
+ sizeof(read_from_pipe));
+
+ a = 0;
+ for (i = 0; i < howmany; i++) {
+ message[a] = read_from_pipe[i];
+ a++;
+
+ if (read_from_pipe[i] == '\0') {
+
+ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
+
+ if (!strcasecmp(message, "ERROR 68")) {
+ DEBUGA_SKYPE
+ ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
+ SKYPIAX_P_LOG);
+ skypiax_sleep(1000000);
+ skypiax_skype_write(tech_pvt, "PROTOCOL 6");
+ skypiax_sleep(10000);
+ return 0;
+ }
- DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
+ if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
+ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ SKYPIAX_P_LOG, message);
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ tech_pvt->skype_call_id[0] = '\0';
+
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ }
- if (!strcasecmp(message, "ERROR 68")) {
- DEBUGA_SKYPE
- ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
- SKYPIAX_P_LOG);
- skypiax_sleep(1000000);
- skypiax_skype_write(tech_pvt, "PROTOCOL 6");
- skypiax_sleep(10000);
- return 0;
- }
+ strncpy(message_2, message, sizeof(message) - 1);
- if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
- ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, message);
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- tech_pvt->skype_call_id[0] = '\0';
+ buf = message;
+ stringp = &buf;
+ where = strsep(stringp, " ");
+ if (!where) {
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
+ }
+ if (!strcasecmp(message, "ERROR")) {
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ tech_pvt->skype_call_id[0] = '\0';
+
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ }
+ if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- }
+ where = strsep(stringp, " ");
- strncpy(message_2, message, sizeof(message) - 1);
+ strncpy(id, where, sizeof(id) - 1);
- buf = message;
- stringp = &buf;
- where = strsep(stringp, " ");
- if (!where) {
- WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
- }
- if (!strcasecmp(message, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- tech_pvt->skype_call_id[0] = '\0';
+ if (!strcasecmp(id, tech_pvt->skype_user)) {
+ tech_pvt->SkypiaxHandles.api_connected = 1;
+ DEBUGA_SKYPE
+ ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
+ }
+ }
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- }
- if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
- strncpy(obj, where, sizeof(obj) - 1);
+ if (!strcasecmp(message, "USER")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- where = strsep(stringp, " ");
+ where = strsep(stringp, " ");
- strncpy(id, where, sizeof(id) - 1);
+ strncpy(id, where, sizeof(id) - 1);
- if (!strcasecmp(id, tech_pvt->skype_user)) {
- tech_pvt->SkypiaxHandles.api_connected = 1;
- DEBUGA_SKYPE
- ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
- }
- }
+ where = strsep(stringp, " ");
- if (!strcasecmp(message, "USER")) {
- strncpy(obj, where, sizeof(obj) - 1);
+ strncpy(prop, where, sizeof(prop) - 1);
- where = strsep(stringp, " ");
+ if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
- strncpy(id, where, sizeof(id) - 1);
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ }
- where = strsep(stringp, " ");
+ if (!strcasecmp(message, "MESSAGE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- strncpy(prop, where, sizeof(prop) - 1);
+ where = strsep(stringp, " ");
- if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop);
+ strncpy(id, where, sizeof(id) - 1);
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
- }
+ where = strsep(stringp, " ");
- if (!strcasecmp(message, "MESSAGE")) {
- strncpy(obj, where, sizeof(obj) - 1);
+ strncpy(prop, where, sizeof(prop) - 1);
- where = strsep(stringp, " ");
+ if (!strcasecmp(prop, "STATUS")) {
- strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(value, where, sizeof(value) - 1);
- strncpy(prop, where, sizeof(prop) - 1);
+ if (!strcasecmp(value, "RECEIVED")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value);
+
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ } else if (!strcasecmp(prop, "BODY")) {
+ char msg_to_skype[256];
- if (!strcasecmp(prop, "STATUS")) {
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
- where = strsep(stringp, " ");
+ //FIXME: TODO: on config param ???
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
- strncpy(value, where, sizeof(value) - 1);
+ }
- if (!strcasecmp(value, "RECEIVED")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE
- ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop, value);
+ if (!strcasecmp(message, "CALL")) {
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
- } else if (!strcasecmp(prop, "BODY")) {
- char msg_to_skype[256];
+ strncpy(obj, where, sizeof(obj) - 1);
- DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop);
+ where = strsep(stringp, " ");
- //FIXME: TODO: on config param ???
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
+ strncpy(id, where, sizeof(id) - 1);
- }
+ where = strsep(stringp, " ");
- if (!strcasecmp(message, "CALL")) {
+ strncpy(prop, where, sizeof(prop) - 1);
- strncpy(obj, where, sizeof(obj) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(value, where, sizeof(value) - 1);
- strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ DEBUGA_SKYPE
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
- strncpy(prop, where, sizeof(prop) - 1);
+ if (!strcasecmp(prop, "PARTNER_HANDLE")) {
+ strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1);
+ DEBUGA_SKYPE
+ ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
+ SKYPIAX_P_LOG, id, tech_pvt->callid_number);
+ return CALLFLOW_INCOMING_RING;
+ }
+ if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
+ snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
+ value, where ? " " : "", where ? where : "");
+ DEBUGA_SKYPE
+ ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
+ SKYPIAX_P_LOG, id, tech_pvt->callid_name);
+ }
+ if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
+ if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
- where = strsep(stringp, " ");
+ if (!strcasecmp(prop, "DTMF")) {
- strncpy(value, where, sizeof(value) - 1);
+ DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
- where = strsep(stringp, " ");
+ dtmf_received(tech_pvt, value);
+ }
+ if (!strcasecmp(prop, "FAILUREREASON")) {
+ DEBUGA_SKYPE
+ ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
+ if (strcasecmp(id, tech_pvt->skype_call_id)) {
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE
- ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
-
- if (!strcasecmp(prop, "PARTNER_HANDLE")) {
- strncpy(tech_pvt->callid_number, value,
- sizeof(tech_pvt->callid_number) - 1);
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_number);
- return CALLFLOW_INCOMING_RING;
- }
- if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
- snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
- value, where ? " " : "", where ? where : "");
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_name);
- }
- if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
- id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
- if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
-
- if (!strcasecmp(prop, "DTMF")) {
-
- DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ }
- dtmf_received(tech_pvt, value);
- }
+ if (!strcasecmp(prop, "STATUS")) {
- if (!strcasecmp(prop, "FAILUREREASON")) {
- DEBUGA_SKYPE
- ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
- SKYPIAX_P_LOG, id);
- }
- if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
- if (strcasecmp(id, tech_pvt->skype_call_id)) {
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
+ /* we are not calling out */
+
+ if (!strlen(tech_pvt->skype_call_id)) { //FIXME
+ /* we are not inside an active call */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RING;
+ /* no owner, no active call, let's answer */
+ skypiax_skype_write(tech_pvt, "SET AGC OFF");
+ skypiax_sleep(10000);
+ skypiax_skype_write(tech_pvt, "SET AEC OFF");
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
+ id);
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ } else {
+ /* we're owned, we're in a call, let's refuse */
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
DEBUGA_SKYPE
- ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
SKYPIAX_P_LOG, id);
+
}
+ } else {
+ /* we are calling out */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
+ //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
+ SKYPIAX_P_LOG, id);
}
+ } else if (!strcasecmp(value, "EARLYMEDIA")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
+ SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
+
+ } else if (!strcasecmp(value, "FINISHED")) {
+ //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
- if (!strcasecmp(prop, "STATUS")) {
-
- if (!strcasecmp(value, "RINGING")) {
- char msg_to_skype[1024];
- if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
-
- if (!strlen(tech_pvt->skype_call_id)) { //FIXME
- /* we are not inside an active call */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- /* no owner, no active call, let's answer */
- skypiax_skype_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_skype_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
- SKYPIAX_P_LOG, id);
- strncpy(tech_pvt->skype_call_id, id,
- sizeof(tech_pvt->skype_call_id) - 1);
- } else {
- /* we're owned, we're in a call, let's refuse */
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- DEBUGA_SKYPE
- ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
- SKYPIAX_P_LOG, id);
-
- }
- } else {
- /* we are calling out */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- strncpy(tech_pvt->skype_call_id, id,
- sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
- SKYPIAX_P_LOG, id);
- }
- } else if (!strcasecmp(value, "EARLYMEDIA")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
- SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "MISSED")) {
- DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
-
- } else if (!strcasecmp(value, "FINISHED")) {
- //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
-
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
-
- } else if (!strcasecmp(value, "CANCELLED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
- SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
-
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- } else if (!strcasecmp(value, "FAILED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
- SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else if (!strcasecmp(value, "REFUSED")) {
- if (!strcasecmp(id, tech_pvt->skype_call_id)) {
- /* this is the id of the call we are in, probably we generated it */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
- SKYPIAX_P_LOG, id);
- strncpy(tech_pvt->skype_call_id, id,
- sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- tech_pvt->skype_call_id[0] = '\0';
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- /* we're here because were us that refused an incoming call */
- DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
-
- }
- } else if (!strcasecmp(value, "ROUTING")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "UNPLACED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "INPROGRESS")) {
- char msg_to_skype[1024];
- tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_UP;
- DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
- tech_pvt->tcp_cli_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- start_audio_threads(tech_pvt);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
- tech_pvt->tcp_srv_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
-
- tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
- if (!strlen(tech_pvt->session_uuid_str)) {
- DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
- new_inbound_channel(tech_pvt);
- } else {
- DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
- outbound_channel_answered(tech_pvt);
- }
+ } else if (!strcasecmp(value, "CANCELLED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
- } else {
- WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
- id, value);
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ } else if (!strcasecmp(value, "FAILED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
+ SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else if (!strcasecmp(value, "REFUSED")) {
+ if (!strcasecmp(id, tech_pvt->skype_call_id)) {
+ /* this is the id of the call we are in, probably we generated it */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ SKYPIAX_P_LOG, id);
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ tech_pvt->skype_call_id[0] = '\0';
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ /* we're here because were us that refused an incoming call */
+ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
- }
- } //STATUS
+ }
+ } else if (!strcasecmp(value, "ROUTING")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "UNPLACED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "INPROGRESS")) {
+ char msg_to_skype[1024];
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_UP;
+ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_cli_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ start_audio_threads(tech_pvt);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_srv_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+
+ tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+
+ if (!strlen(tech_pvt->session_uuid_str)) {
+ DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
+ new_inbound_channel(tech_pvt);
+ } else {
+ DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
+ outbound_channel_answered(tech_pvt);
+ }
- } //CALL
+ } else {
+ WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
+ value);
- /* the "numbered" messages that follows are used by the directory application, not yet ported */
- if (!strcasecmp(message, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[11]); */
- memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
- }
- if (!strcasecmp(message, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
- }
- if (!strcasecmp(message, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
}
+ } //STATUS
- a = 0;
- } //message end
- } //read_from_pipe
+ } //CALL
+ /* the "numbered" messages that follows are used by the directory application, not yet ported */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
+ memset(tech_pvt->skype_friends, 0, 4096);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
+ }
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_fullname, 0, 512);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
+ }
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_displayname, 0, 512);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
+ }
+
+ a = 0;
+ } //message end
+ } //read_from_pipe
return 0;
}
1
0
Author: gmaruzz
Date: Mon Feb 9 12:26:31 2009
New Revision: 11715
Log:
skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:26:31 2009
@@ -352,8 +352,7 @@
DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
- if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified,
- just authorized */
+ if (!strcasecmp(message, "ERROR 68")) {
DEBUGA_SKYPE
("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
SKYPIAX_P_LOG);
@@ -386,25 +385,6 @@
if (!where) {
WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
}
-
- if (!strcasecmp(message, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[11]); */
- memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
- }
- if (!strcasecmp(message, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
- }
- if (!strcasecmp(message, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
- }
if (!strcasecmp(message, "ERROR")) {
ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
@@ -716,6 +696,26 @@
} //CALL
+ /* the "numbered" messages that follows are used by the directory application, not yet ported */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
+ memset(tech_pvt->skype_friends, 0, 4096);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
+ }
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_fullname, 0, 512);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
+ }
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_displayname, 0, 512);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
+ }
+
a = 0;
} //message end
} //read_from_pipe
1
0
Author: gmaruzz
Date: Mon Feb 9 12:10:52 2009
New Revision: 11714
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:10:52 2009
@@ -327,53 +327,32 @@
{
char read_from_pipe[4096];
- char messaggio[4096];
- char messaggio_2[4096];
+ char message[4096];
+ char message_2[4096];
char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
char **stringp = NULL;
- int rt;
int a;
unsigned int howmany;
unsigned int i;
-#ifndef WIN32
- int fdselect;
- fd_set fs;
- struct timeval to;
-#endif /* WIN32 */
memset(read_from_pipe, 0, 4096);
- memset(messaggio, 0, 4096);
- memset(messaggio_2, 0, 4096);
+ memset(message, 0, 4096);
+ memset(message_2, 0, 4096);
-#ifdef WIN32
- rt = 1;
-#else /* WIN32 */
- fdselect = tech_pvt->SkypiaxHandles.fdesc[0];
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //500 msec
- to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-#endif /* WIN32 */
-
- if (rt > 0) {
- if (tech_pvt->SkypiaxHandles.fdesc[0]) {
- howmany = sizeof(read_from_pipe);
howmany =
skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
- howmany);
+ sizeof(read_from_pipe));
a = 0;
for (i = 0; i < howmany; i++) {
- messaggio[a] = read_from_pipe[i];
+ message[a] = read_from_pipe[i];
a++;
if (read_from_pipe[i] == '\0') {
- //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio);
- DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio);
+ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
- if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
+ if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified,
just authorized */
DEBUGA_SKYPE
("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
@@ -384,9 +363,9 @@
return 0;
}
- if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
+ if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, messaggio);
+ SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@@ -399,35 +378,35 @@
}
}
- strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
+ strncpy(message_2, message, sizeof(message) - 1);
- buf = messaggio;
+ buf = message;
stringp = &buf;
where = strsep(stringp, " ");
if (!where) {
- WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
}
- if (!strcasecmp(messaggio, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[11]); */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
}
- if (!strcasecmp(messaggio, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
}
- if (!strcasecmp(messaggio, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
}
- if (!strcasecmp(messaggio, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
+ if (!strcasecmp(message, "ERROR")) {
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@@ -439,7 +418,7 @@
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
}
}
- if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
+ if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -449,12 +428,12 @@
if (!strcasecmp(id, tech_pvt->skype_user)) {
tech_pvt->SkypiaxHandles.api_connected = 1;
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user);
+ ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
}
}
- if (!strcasecmp(messaggio, "USER")) {
+ if (!strcasecmp(message, "USER")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -467,8 +446,8 @@
if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
//FIXME: TODO: allow authorization based on config param
sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
@@ -476,7 +455,7 @@
}
}
- if (!strcasecmp(messaggio, "MESSAGE")) {
+ if (!strcasecmp(message, "MESSAGE")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -496,8 +475,8 @@
if (!strcasecmp(value, "RECEIVED")) {
char msg_to_skype[256];
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value);
//FIXME: TODO: allow authorization based on config param
sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
@@ -506,8 +485,8 @@
} else if (!strcasecmp(prop, "BODY")) {
char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
//FIXME: TODO: on config param ???
sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
@@ -516,7 +495,7 @@
}
- if (!strcasecmp(messaggio, "CALL")) {
+ if (!strcasecmp(message, "CALL")) {
strncpy(obj, where, sizeof(obj) - 1);
@@ -535,8 +514,8 @@
where = strsep(stringp, " ");
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
if (!strcasecmp(prop, "PARTNER_HANDLE")) {
strncpy(tech_pvt->callid_number, value,
@@ -741,8 +720,6 @@
} //message end
} //read_from_pipe
- }
- }
return 0;
}
1
0