[asterisk-commits] qwell: trunk r77884 - in /trunk: ./ channels/chan_skinny.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Aug 1 16:12:03 CDT 2007
Author: qwell
Date: Wed Aug 1 16:12:02 2007
New Revision: 77884
URL: http://svn.digium.com/view/asterisk?view=rev&rev=77884
Log:
Merged revisions 77883 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r77883 | qwell | 2007-08-01 16:08:42 -0500 (Wed, 01 Aug 2007) | 7 lines
Fix an issue that caused one-way audio on some newer devices (specifically the 7921),
due to sending packets in the wrong order during hangup.
Also make sure we clear tones/messages on the correct line/instance.
Issue 10291, patch by DEA, tested by sbisker and myself.
........
Modified:
trunk/ (props changed)
trunk/channels/chan_skinny.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=77884&r1=77883&r2=77884
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Wed Aug 1 16:12:02 2007
@@ -283,12 +283,15 @@
#define START_TONE_MESSAGE 0x0082
struct start_tone_message {
uint32_t tone;
- uint32_t space[3];
+ uint32_t space;
+ uint32_t instance;
+ uint32_t reference;
};
#define STOP_TONE_MESSAGE 0x0083
struct stop_tone_message {
- uint32_t space[2];
+ uint32_t instance;
+ uint32_t reference;
};
#define SET_RINGER_MESSAGE 0x0085
@@ -742,6 +745,7 @@
struct clear_prompt_message clearpromptstatus;
struct definetimedate_message definetimedate;
struct start_tone_message starttone;
+ struct stop_tone_message stoptone;
struct speed_dial_stat_res_message speeddial;
struct line_state_req_message line;
struct line_stat_res_message linestat;
@@ -1629,43 +1633,43 @@
{
struct skinny_req *req;
+ if (state == SKINNY_OFFHOOK) {
+ if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
+ return;
+
+ req->data.activatecallplane.lineInstance = htolel(instance);
+ transmit_response(s, req);
+ } else if (state == SKINNY_ONHOOK) {
+ transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
+
+ if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
+ return;
+
+ req->data.activatecallplane.lineInstance = htolel(instance);
+ transmit_response(s, req);
+
+ if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE)))
+ return;
+
+ req->data.closereceivechannel.conferenceId = htolel(callid);
+ req->data.closereceivechannel.partyId = htolel(callid);
+ transmit_response(s, req);
+
+ if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
+ return;
+
+ req->data.stopmedia.conferenceId = htolel(callid);
+ req->data.stopmedia.passThruPartyId = htolel(callid);
+ transmit_response(s, req);
+ }
+
if (!(req = req_alloc(sizeof(struct call_state_message), CALL_STATE_MESSAGE)))
return;
- if (state == SKINNY_ONHOOK) {
- transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
- }
req->data.callstate.callState = htolel(state);
req->data.callstate.lineInstance = htolel(instance);
req->data.callstate.callReference = htolel(callid);
transmit_response(s, req);
- if (state == SKINNY_OFFHOOK) {
- if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
- return;
-
- req->data.activatecallplane.lineInstance = htolel(instance);
- transmit_response(s, req);
- } else if (state == SKINNY_ONHOOK) {
- if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
- return;
-
- req->data.activatecallplane.lineInstance = htolel(instance);
- transmit_response(s, req);
-
- if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE)))
- return;
-
- req->data.closereceivechannel.conferenceId = 0;
- req->data.closereceivechannel.partyId = htolel(callid);
- transmit_response(s, req);
-
- if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
- return;
-
- req->data.stopmedia.conferenceId = 0;
- req->data.stopmedia.passThruPartyId = htolel(callid);
- transmit_response(s, req);
- }
}
static void transmit_callinfo(struct skinnysession *s, const char *fromname, const char *fromnum, const char *toname, const char *tonum, int instance, int callid, int calltype)
@@ -1707,7 +1711,7 @@
fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
- req->data.openreceivechannel.conferenceId = htolel(0);
+ req->data.openreceivechannel.conferenceId = htolel(sub->callid);
req->data.openreceivechannel.partyId = htolel(sub->callid);
req->data.openreceivechannel.packets = htolel(fmt.cur_ms);
req->data.openreceivechannel.capability = htolel(codec_ast2skinny(fmt.bits));
@@ -1716,7 +1720,7 @@
transmit_response(s, req);
}
-static void transmit_tone(struct skinnysession *s, int tone)
+static void transmit_tone(struct skinnysession *s, int tone, int instance, int reference)
{
struct skinny_req *req;
@@ -1728,9 +1732,14 @@
if (tone > 0) {
if (!(req = req_alloc(sizeof(struct start_tone_message), START_TONE_MESSAGE)))
return;
+ req->data.starttone.tone = htolel(tone);
+ req->data.starttone.instance = htolel(instance);
+ req->data.starttone.reference = htolel(reference);
} else {
if (!(req = req_alloc(sizeof(struct stop_tone_message), STOP_TONE_MESSAGE)))
return;
+ req->data.stoptone.instance = htolel(instance);
+ req->data.stoptone.reference = htolel(reference);
}
if (tone > 0) {
@@ -1791,13 +1800,16 @@
transmit_response(s, req);
}
-static void transmit_displaymessage(struct skinnysession *s, const char *text)
+static void transmit_displaymessage(struct skinnysession *s, const char *text, int instance, int reference)
{
struct skinny_req *req;
if (text == 0) {
if (!(req = req_alloc(0, CLEAR_DISPLAY_MESSAGE)))
return;
+
+ req->data.clearpromptstatus.lineInstance = instance;
+ req->data.clearpromptstatus.callReference = reference;
if (skinnydebug)
ast_verbose("Clearing Display\n");
@@ -2515,7 +2527,7 @@
res = ast_pbx_run(c);
if (res) {
ast_log(LOG_WARNING, "PBX exited non-zero\n");
- transmit_tone(s, SKINNY_REORDER);
+ transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid);
}
return NULL;
}
@@ -2553,7 +2565,7 @@
len = strlen(d->exten);
if (!ast_ignore_pattern(c->context, d->exten)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
if (ast_exists_extension(c, c->context, d->exten, 1, l->cid_num)) {
if (!res || !ast_matchmore_extension(c, c->context, d->exten, 1, l->cid_num)) {
@@ -2562,7 +2574,7 @@
ast_copy_string(l->call_forward, d->exten, sizeof(l->call_forward));
ast_verb(3, "Setting call forward to '%s' on channel %s\n",
l->call_forward, c->name);
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
if (res) {
break;
}
@@ -2570,7 +2582,7 @@
ast_indicate(c, -1);
ast_safe_sleep(c, 1000);
memset(d->exten, 0, sizeof(d->exten));
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
len = 0;
getforward = 0;
} else {
@@ -2588,7 +2600,7 @@
} else if (res == 0) {
ast_debug(1, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
memset(d->exten, 0, sizeof(d->exten));
- transmit_tone(s, SKINNY_REORDER);
+ transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid);
if (sub->owner && sub->owner->_state != AST_STATE_UP) {
ast_indicate(c, -1);
ast_hangup(c);
@@ -2598,7 +2610,7 @@
((d->exten[0] != '*') || (!ast_strlen_zero(d->exten) > 2))) {
ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", d->exten, c->cid.cid_num ? c->cid.cid_num : "<Unknown Caller>", c->context);
memset(d->exten, 0, sizeof(d->exten));
- transmit_tone(s, SKINNY_REORDER);
+ transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid);
/* hang out for 3 seconds to let congestion play */
ast_safe_sleep(c, 3000);
break;
@@ -2694,10 +2706,9 @@
transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
} else if ((l->type = TYPE_LINE) && (l->hookstate == SKINNY_ONHOOK)) {
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
- transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
transmit_ringer_mode(s, SKINNY_RING_OFF);
- transmit_tone(s, SKINNY_SILENCE);
transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
do_housekeeping(s);
}
@@ -2733,7 +2744,7 @@
ast_setstate(ast, AST_STATE_UP);
}
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
/* order matters here...
for some reason, transmit_callinfo must be before transmit_callstate,
or you won't get keypad messages in some situations. */
@@ -2856,7 +2867,7 @@
int tmp;
/* not right */
sprintf(tmp, "%d", digit);
- transmit_tone(d->session, digit);
+ transmit_tone(d->session, digit, l->instance, sub->callid);
#endif
return -1; /* Stop inband indications */
}
@@ -2923,7 +2934,7 @@
case AST_CONTROL_RINGING:
if (ast->_state != AST_STATE_UP) {
if (!sub->progress) {
- transmit_tone(s, SKINNY_ALERT);
+ transmit_tone(s, SKINNY_ALERT, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_RINGOUT, sub->callid);
transmit_dialednumber(s, ast->exten, l->instance, sub->callid);
transmit_displaypromptstatus(s, "Ring Out", 0, l->instance, sub->callid);
@@ -2935,7 +2946,7 @@
return -1;
case AST_CONTROL_BUSY:
if (ast->_state != AST_STATE_UP) {
- transmit_tone(s, SKINNY_BUSYTONE);
+ transmit_tone(s, SKINNY_BUSYTONE, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_BUSY, sub->callid);
sub->alreadygone = 1;
ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
@@ -2944,7 +2955,7 @@
return -1;
case AST_CONTROL_CONGESTION:
if (ast->_state != AST_STATE_UP) {
- transmit_tone(s, SKINNY_REORDER);
+ transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_CONGESTION, sub->callid);
sub->alreadygone = 1;
ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
@@ -2953,7 +2964,7 @@
return -1;
case AST_CONTROL_PROGRESS:
if ((ast->_state != AST_STATE_UP) && !sub->progress && !sub->outgoing) {
- transmit_tone(s, SKINNY_ALERT);
+ transmit_tone(s, SKINNY_ALERT, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_PROGRESS, sub->callid);
transmit_displaypromptstatus(s, "Call Progress", 0, l->instance, sub->callid);
transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, ast->exten, ast->exten, l->instance, sub->callid, 2); /* 2 = outgoing from phone */
@@ -2962,7 +2973,7 @@
}
return -1;
case -1:
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
break;
case AST_CONTROL_HOLD:
ast_moh_start(ast, data, l->mohinterpret);
@@ -3093,14 +3104,14 @@
if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE)))
return 0;
- req->data.closereceivechannel.conferenceId = htolel(0);
+ req->data.closereceivechannel.conferenceId = htolel(sub->callid);
req->data.closereceivechannel.partyId = htolel(sub->callid);
transmit_response(s, req);
if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
return 0;
- req->data.stopmedia.conferenceId = htolel(0);
+ req->data.stopmedia.conferenceId = htolel(sub->callid);
req->data.stopmedia.passThruPartyId = htolel(sub->callid);
transmit_response(s, req);
@@ -3320,12 +3331,12 @@
}
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT);
if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten));
if (ast_pthread_create(&t, NULL, skinny_newcall, c)) {
@@ -3361,12 +3372,12 @@
}
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT);
if (!ast_ignore_pattern(c->context, sd->exten)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
if (ast_exists_extension(c, c->context, sd->exten, 1, l->cid_num)) {
ast_copy_string(c->exten, sd->exten, sizeof(c->exten));
@@ -3431,12 +3442,12 @@
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT);
if (!ast_ignore_pattern(c->context, vmexten)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
if (ast_exists_extension(c, c->context, l->vmexten, 1, l->cid_num)) {
@@ -3510,7 +3521,7 @@
/* We're answering a ringing call */
ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
@@ -3526,8 +3537,8 @@
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
/* start the switch thread */
@@ -3590,7 +3601,7 @@
/* We're answering a ringing call */
ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
start_rtp(sub);
@@ -3605,8 +3616,8 @@
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
/* start the switch thread */
@@ -4040,7 +4051,7 @@
if (skinnydebug)
ast_verbose("Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
- req->data.startmedia.conferenceId = htolel(0);
+ req->data.startmedia.conferenceId = htolel(sub->callid);
req->data.startmedia.passThruPartyId = htolel(sub->callid);
req->data.startmedia.remoteIp = htolel(d->ourip.s_addr);
req->data.startmedia.remotePort = htolel(ntohs(us.sin_port));
@@ -4088,11 +4099,11 @@
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
if (!ast_ignore_pattern(c->context, req->data.enbloccallmessage.calledParty)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
ast_copy_string(c->exten, req->data.enbloccallmessage.calledParty, sizeof(c->exten));
if (ast_pthread_create(&t, NULL, skinny_newcall, c)) {
@@ -4205,12 +4216,12 @@
}
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT);
if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) {
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
}
ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten));
if (ast_pthread_create(&t, NULL, skinny_newcall, c)) {
@@ -4246,8 +4257,8 @@
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
- transmit_displaymessage(s, NULL); /* clear display */
- transmit_tone(s, SKINNY_DIALTONE);
+ transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */
+ transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
/* start the switch thread */
@@ -4366,7 +4377,7 @@
/* We're answering a ringing call */
ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
- transmit_tone(s, SKINNY_SILENCE);
+ transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid);
transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
start_rtp(sub);
More information about the asterisk-commits
mailing list