ERRORA("skypopen_tech_init: no tech_pvt->session_uuid_str\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
- if (skypopen_codec(tech_pvt, SAMPLERATE_SKYPOPEN, 20) != SWITCH_STATUS_SUCCESS) {
+ if (skypopen_codec(tech_pvt, SAMPLERATE_SKYPOPEN, MS_SKYPOPEN) != SWITCH_STATUS_SUCCESS) {
ERRORA("skypopen_tech_init: skypopen_codec FAILED\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
tech_pvt->read_frame.flags = SFF_NONE;
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
- switch_sleep(20000);
+ switch_sleep(MS_SKYPOPEN * 1000);
return SWITCH_STATUS_FALSE;
}
if (!switch_channel_ready(channel)) {
ERRORA("channel not ready \n", SKYPOPEN_P_LOG);
- switch_sleep(20000);
+ switch_sleep(MS_SKYPOPEN * 1000);
return SWITCH_STATUS_FALSE;
}
if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) {
//DEBUGA_SKYPE("CHANNEL READ FRAME in TFLAG_PROGRESS goto CNG\n", SKYPOPEN_P_LOG);
- switch_sleep(20000);
+ switch_sleep(MS_SKYPOPEN * 1000);
goto cng;
}
if (!tech_pvt->read_buffer) {
- int32_t max_len = 640 * 10;
+ int32_t max_len = BYTES_PER_FRAME * 10;
switch_buffer_create(skypopen_module_pool, &tech_pvt->read_buffer, max_len);
switch_assert(tech_pvt->read_buffer);
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) {
switch_mutex_lock(tech_pvt->mutex_audio_srv);
if (tech_pvt->read_buffer && switch_buffer_inuse(tech_pvt->read_buffer)) {
- bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, 640);
+ bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, BYTES_PER_FRAME);
tech_pvt->read_frame.datalen = bytes_read;
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
if (try < 5)
goto read;
DEBUGA_SKYPE("skypopen_audio_read Silence\n", SKYPOPEN_P_LOG);
- memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
- tech_pvt->read_frame.datalen = 640;
+ memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME);
+ tech_pvt->read_frame.datalen = BYTES_PER_FRAME;
}
} else {
- memset(tech_pvt->read_frame.data, 255, SAMPLES_PER_FRAME * sizeof(short));
- tech_pvt->read_frame.datalen = 640;
+ memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME);
+ tech_pvt->read_frame.datalen = BYTES_PER_FRAME;
}
switch_mutex_lock(tech_pvt->flag_mutex);
}
#endif
if (!tech_pvt->write_buffer) {
- int32_t max_len = 640 * 3;
+ int32_t max_len = BYTES_PER_FRAME * 3;
switch_buffer_create(skypopen_module_pool, &tech_pvt->write_buffer, max_len);
switch_assert(tech_pvt->write_buffer);
switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen);
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
if (no_space) {
- switch_sleep(20000);
+ switch_sleep(MS_SKYPOPEN * 1000);
} else {
tech_pvt->begin_to_write = 1;
}
tech_pvt->begin_to_write = 0;
tech_pvt->begin_to_read = 0;
- if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, 320, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_timer_init(&tech_pvt->timer_read, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
switch_core_timer_sync(&tech_pvt->timer_read);
- if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, 320, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_timer_init(&tech_pvt->timer_write, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) {
ERRORA("setup timer failed\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
if (!(running && tech_pvt->running))
break;
FD_ZERO(&fsgio);
- togio.tv_usec = 20000; //20msec
+ togio.tv_usec = MS_SKYPOPEN * 1000;
togio.tv_sec = 0;
fdselectgio = s;
FD_SET(fdselectgio, &fsgio);
fdselect = fd;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 60000; //60 msec
+ to.tv_usec = MS_SKYPOPEN * 1000 * 3;
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (rt > 0) {
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
- len = recv(fd, (char *) srv_in, 640, 0);
+ len = recv(fd, (char *) srv_in, BYTES_PER_FRAME, 0);
} else {
skypopen_sleep(10000);
continue;
if (tech_pvt->read_buffer) {
if (switch_buffer_freespace(tech_pvt->read_buffer) < len) {
switch_buffer_zero(tech_pvt->read_buffer);
+ switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
nospace = 1;
+ } else {
+ switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
}
- switch_buffer_write(tech_pvt->read_buffer, srv_in, len);
}
switch_mutex_unlock(tech_pvt->mutex_audio_srv);
if (nospace) {
- DEBUGA_SKYPE("NO SPACE READ: there was no space for: %d\n", SKYPOPEN_P_LOG, len);
+ WARNINGA("NO SPACE READ: there was no space for: %d\n", SKYPOPEN_P_LOG, len);
}
} else if (len == 0) {
DEBUGA_SKYPE("CLOSED\n", SKYPOPEN_P_LOG);
if (!(running && tech_pvt->running))
break;
FD_ZERO(&fsgio);
- togio.tv_usec = 60000; //60msec
+ togio.tv_usec = MS_SKYPOPEN * 1000 * 3;
togio.tv_sec = 0;
fdselectgio = s;
FD_SET(fdselectgio, &fsgio);
if (tech_pvt->begin_to_write == 0) {
memset(cli_out, 255, sizeof(cli_out));
- bytes_to_write = 640;
+ bytes_to_write = BYTES_PER_FRAME;
len = send(fd, (char *) cli_out, bytes_to_write, 0);
if (len == -1) {
DEBUGA_SKYPE("len=%d, error: %s\n", SKYPOPEN_P_LOG, len, strerror(errno));
}
switch_mutex_lock(tech_pvt->mutex_audio_cli);
if (tech_pvt->write_buffer && switch_buffer_inuse(tech_pvt->write_buffer)) {
- bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, 640);
+ bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, BYTES_PER_FRAME);
}
switch_mutex_unlock(tech_pvt->mutex_audio_cli);
if (!bytes_to_write) {
if (tech_pvt->write_silence_when_idle) {
memset(cli_out, 255, sizeof(cli_out));
- bytes_to_write = 640;
+ bytes_to_write = BYTES_PER_FRAME;
//DEBUGA_SKYPE("WRITE Silence!\n", SKYPOPEN_P_LOG);
} else {
continue;
char msg_to_skype[1024];
DEBUGA_SKYPE("DIGIT received: %c\n", SKYPOPEN_P_LOG, digit);
- sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
- skypopen_signaling_write(tech_pvt, msg_to_skype);
+ if(digit != 'a' && digit != 'A' && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D'){
+ sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
+ skypopen_signaling_write(tech_pvt, msg_to_skype);
+ } else {
+ WARNINGA("Received DTMF DIGIT \"%c\", but not relayed to Skype client because Skype client accepts only 0-9*#\n", SKYPOPEN_P_LOG, digit);
+ }
return 0;
}