mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
skypiax: now it manages the REMOTEHOLD status, when the remote party puts the call on-hold
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13667 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e8a262b729
commit
0b0d4077c1
@ -126,6 +126,7 @@ typedef enum {
|
|||||||
#define SKYPIAX_STATE_HANGUP_REQUESTED 200
|
#define SKYPIAX_STATE_HANGUP_REQUESTED 200
|
||||||
//FIXME CALLFLOW_INCOMING_CALLID to be removed
|
//FIXME CALLFLOW_INCOMING_CALLID to be removed
|
||||||
#define CALLFLOW_INCOMING_CALLID 1019
|
#define CALLFLOW_INCOMING_CALLID 1019
|
||||||
|
#define CALLFLOW_STATUS_REMOTEHOLD 201
|
||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
|
|
||||||
|
@ -369,40 +369,50 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
|||||||
skypiax_strncpy(tech_pvt->skype_call_id, id,
|
skypiax_strncpy(tech_pvt->skype_call_id, id,
|
||||||
sizeof(tech_pvt->skype_call_id) - 1);
|
sizeof(tech_pvt->skype_call_id) - 1);
|
||||||
DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
|
DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
|
||||||
} else if (!strcasecmp(value, "INPROGRESS")) {
|
} else if (!strcasecmp(value, "INPROGRESS")) {
|
||||||
char msg_to_skype[1024];
|
char msg_to_skype[1024];
|
||||||
|
|
||||||
if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
|| !strcasecmp(tech_pvt->skype_call_id, id)) {
|
if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
|
||||||
skypiax_strncpy(tech_pvt->skype_call_id, id,
|
|| !strcasecmp(tech_pvt->skype_call_id, id)) {
|
||||||
sizeof(tech_pvt->skype_call_id) - 1);
|
skypiax_strncpy(tech_pvt->skype_call_id, id,
|
||||||
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
|
sizeof(tech_pvt->skype_call_id) - 1);
|
||||||
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
|
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
|
||||||
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
|
|
||||||
tech_pvt->interface_state = SKYPIAX_STATE_UP;
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
|
||||||
start_audio_threads(tech_pvt);
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
|
||||||
skypiax_sleep(1000); //FIXME
|
tech_pvt->interface_state = SKYPIAX_STATE_UP;
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
start_audio_threads(tech_pvt);
|
||||||
tech_pvt->tcp_cli_port);
|
skypiax_sleep(1000); //FIXME
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
||||||
skypiax_sleep(1000); //FIXME
|
tech_pvt->tcp_cli_port);
|
||||||
sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
tech_pvt->tcp_srv_port);
|
skypiax_sleep(1000); //FIXME
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
||||||
}
|
tech_pvt->tcp_srv_port);
|
||||||
tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
if (!strlen(tech_pvt->session_uuid_str)) {
|
}
|
||||||
DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
|
tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
|
||||||
new_inbound_channel(tech_pvt);
|
if (!strlen(tech_pvt->session_uuid_str)) {
|
||||||
} else {
|
DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
|
||||||
DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
|
new_inbound_channel(tech_pvt);
|
||||||
outbound_channel_answered(tech_pvt);
|
} else {
|
||||||
}
|
DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
|
||||||
} else {
|
outbound_channel_answered(tech_pvt);
|
||||||
DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n",
|
}
|
||||||
SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
|
} else {
|
||||||
}
|
DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n",
|
||||||
} else {
|
SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
|
||||||
|
WARNINGA("Back from REMOTEHOLD!\n", SKYPIAX_P_LOG);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (!strcasecmp(value, "REMOTEHOLD")) {
|
||||||
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_REMOTEHOLD;
|
||||||
|
WARNINGA("skype_call: %s is now REMOTEHOLD\n", SKYPIAX_P_LOG, id);
|
||||||
|
} else {
|
||||||
WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
|
WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
@ -485,6 +495,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
||||||
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
|
||||||
|| tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
|| tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
||||||
|
|
||||||
unsigned int fdselect;
|
unsigned int fdselect;
|
||||||
@ -506,61 +517,65 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
|||||||
if (rt > 0) {
|
if (rt > 0) {
|
||||||
|
|
||||||
#ifdef FARMING
|
#ifdef FARMING
|
||||||
switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-)
|
switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-)
|
||||||
#endif // FARMING
|
#endif // FARMING
|
||||||
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
|
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
|
||||||
|
} else {
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (len == 320) {
|
if (len == 320) {
|
||||||
unsigned int howmany;
|
unsigned int howmany;
|
||||||
|
|
||||||
if (samplerate_skypiax == 8000) {
|
if (samplerate_skypiax == 8000) {
|
||||||
/* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
|
/* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
|
||||||
a = 0;
|
a = 0;
|
||||||
for (i = 0; i < len / sizeof(short); i++) {
|
for (i = 0; i < len / sizeof(short); i++) {
|
||||||
srv_out[a] = srv_in[i];
|
srv_out[a] = srv_in[i];
|
||||||
i++;
|
i++;
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
} else if (samplerate_skypiax == 16000) {
|
} else if (samplerate_skypiax == 16000) {
|
||||||
/* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
|
/* we're NOT downsampling, srv_out will contain ALL samples from srv_in */
|
||||||
for (i = 0; i < len / sizeof(short); i++) {
|
for (i = 0; i < len / sizeof(short); i++) {
|
||||||
srv_out[i] = srv_in[i];
|
srv_out[i] = srv_in[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
|
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 not yet done, let's store the half incoming frame */
|
||||||
if (!tech_pvt->audiobuf_is_loaded) {
|
if (!tech_pvt->audiobuf_is_loaded) {
|
||||||
for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
|
for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
|
||||||
tech_pvt->audiobuf[i] = srv_out[i];
|
tech_pvt->audiobuf[i] = srv_out[i];
|
||||||
}
|
}
|
||||||
tech_pvt->audiobuf_is_loaded = 1;
|
tech_pvt->audiobuf_is_loaded = 1;
|
||||||
} else {
|
} else {
|
||||||
/* we got a stored half frame, build a complete frame in totalbuf using the stored half frame and the current half frame */
|
/* 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++) {
|
for (i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
|
||||||
totalbuf[i] = tech_pvt->audiobuf[i];
|
totalbuf[i] = tech_pvt->audiobuf[i];
|
||||||
}
|
}
|
||||||
for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
|
for (a = 0; a < SAMPLES_PER_FRAME / 2; a++) {
|
||||||
totalbuf[i] = srv_out[a];
|
totalbuf[i] = srv_out[a];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
/* send the complete frame through the pipe to our code waiting for incoming audio */
|
/* send the complete frame through the pipe to our code waiting for incoming audio */
|
||||||
howmany =
|
howmany =
|
||||||
skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
|
skypiax_pipe_write(tech_pvt->audiopipe[1], totalbuf,
|
||||||
SAMPLES_PER_FRAME * sizeof(short));
|
SAMPLES_PER_FRAME * sizeof(short));
|
||||||
if (howmany != 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,
|
ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany,
|
||||||
(int) (SAMPLES_PER_FRAME * sizeof(short)));
|
(int) (SAMPLES_PER_FRAME * sizeof(short)));
|
||||||
}
|
}
|
||||||
/* done with the stored half frame */
|
/* done with the stored half frame */
|
||||||
tech_pvt->audiobuf_is_loaded = 0;
|
tech_pvt->audiobuf_is_loaded = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (len == 0) {
|
} else if (len == 0) {
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
} else {
|
} else {
|
||||||
ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
|
ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (rt)
|
if (rt)
|
||||||
@ -642,6 +657,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
||||||
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD
|
||||||
|| tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
|| tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
||||||
unsigned int fdselect;
|
unsigned int fdselect;
|
||||||
int rt;
|
int rt;
|
||||||
@ -699,16 +715,18 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
|
/* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
|
||||||
len = send(fd, (char *) cli_out, got, 0);
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
skypiax_sleep(5000); //5 msec
|
len = send(fd, (char *) cli_out, got, 0);
|
||||||
|
skypiax_sleep(5000); //5 msec
|
||||||
|
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
break;
|
break;
|
||||||
} else if (len != got) {
|
} else if (len != got) {
|
||||||
ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
|
ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -719,9 +737,17 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
|||||||
if (rt)
|
if (rt)
|
||||||
ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
|
ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
|
||||||
memset(cli_out, 0, sizeof(cli_out));
|
memset(cli_out, 0, sizeof(cli_out));
|
||||||
len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
|
len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
|
||||||
//DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
|
len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
|
||||||
|
//WARNINGA("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
XXX do nothing
|
||||||
|
*/
|
||||||
|
//WARNINGA("we don't send it\n", SKYPIAX_P_LOG);
|
||||||
|
}
|
||||||
|
skypiax_sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user