[asterisk-commits] trunk r30132 - in /trunk/channels: ./ misdn/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed May 24 16:21:04 MST 2006
Author: crichter
Date: Wed May 24 18:21:03 2006
New Revision: 30132
URL: http://svn.digium.com/view/asterisk?rev=30132&view=rev
Log:
added EVENT_NEW_CHANNEL. We change the channel name now when we got the real channel, also changed name generation to new stringfield api
Modified:
trunk/channels/chan_misdn.c
trunk/channels/misdn/isdn_lib.c
trunk/channels/misdn/isdn_lib.h
trunk/channels/misdn/isdn_msg_parser.c
Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=30132&r1=30131&r2=30132&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Wed May 24 18:21:03 2006
@@ -2588,25 +2588,32 @@
static unsigned long glob_channel=0;
-static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char *exten, char *callerid, int format, int port, int c)
-{
- struct ast_channel *tmp;
-
- tmp = ast_channel_alloc(1);
-
- if (tmp) {
- chan_misdn_log(2, 0, " --> * NEW CHANNEL dad:%s oad:%s\n",exten,callerid);
-
-
- if (c<=0) {
+static void update_name(struct ast_channel *tmp, int port, int c)
+{
+ if (c<=0) {
c=glob_channel++;
ast_string_field_build(tmp, name, "%s/%d-u%d",
misdn_type, port, c);
- } else {
- ast_string_field_build(tmp, name, "%s/%d-%d",
+ } else {
+ ast_string_field_build(tmp, name, "%s/%d-%d",
misdn_type, port, c);
- }
-
+ }
+
+ chan_misdn_log(3,port," --> updating channel name to [%s]\n",tmp->name);
+
+}
+
+static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char *exten, char *callerid, int format, int port, int c)
+{
+ struct ast_channel *tmp;
+
+ tmp = ast_channel_alloc(1);
+
+ if (tmp) {
+ chan_misdn_log(2, 0, " --> * NEW CHANNEL dad:%s oad:%s\n",exten,callerid);
+
+ update_name(tmp,port,c);
+
tmp->nativeformats = prefformat;
tmp->readformat = format;
@@ -3099,10 +3106,13 @@
switch (event) {
-
+
case EVENT_BCHAN_ACTIVATED:
break;
+ case EVENT_NEW_CHANNEL:
+ update_name(ch->ast,bc->port,bc->channel);
+ break;
case EVENT_NEW_L3ID:
ch->l3id=bc->l3_id;
@@ -3421,6 +3431,10 @@
case EVENT_SETUP_ACKNOWLEDGE:
{
ch->state = MISDN_CALLING_ACKNOWLEDGE;
+
+ if (bc->channel)
+ update_name(ch->ast,bc->port,bc->channel);
+
if (!ast_strlen_zero(bc->infos_pending)) {
/* TX Pending Infos */
Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=30132&r1=30131&r2=30132&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Wed May 24 18:21:03 2006
@@ -370,7 +370,7 @@
-static int find_free_chan_in_stack(struct misdn_stack *stack, int channel)
+static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel)
{
int i;
@@ -386,6 +386,8 @@
if (!stack->channels[i]) {
cb_log (4, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
stack->channels[i] = 1;
+ bc->channel=i+1;
+ cb_event(EVENT_NEW_CHANNEL, bc, NULL);
return i+1;
}
}
@@ -772,9 +774,9 @@
int free_chan;
if (stack->nt) {
- free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0);
+ free_chan = find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0);
if (!free_chan) return -1;
- bc->channel=free_chan;
+ /*bc->channel=free_chan;*/
cb_log(4,stack->port, " --> found channel: %d\n",free_chan);
@@ -805,9 +807,9 @@
} else {
if (stack->ptp || bc->te_choose_channel) {
/* we know exactly which channels are in use */
- free_chan = find_free_chan_in_stack(stack, bc->channel_preselected?bc->channel:0);
+ free_chan = find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0);
if (!free_chan) return -1;
- bc->channel=free_chan;
+ /*bc->channel=free_chan;*/
cb_log(0,stack->port, " --> found channel: %d\n",free_chan);
} else {
/* other phones could have made a call also on this port (ptmp) */
@@ -1397,7 +1399,7 @@
{
if (bc->channel == 0xff) {
- bc->channel=find_free_chan_in_stack(stack, 0);
+ bc->channel=find_free_chan_in_stack(stack, bc, 0);
if (!bc->channel) {
cb_log(-1, stack->port, "Any Channel Requested, but we have no more!!\n");
break;
@@ -2877,7 +2879,7 @@
case EVENT_RETRIEVE_ACKNOWLEDGE:
if (stack->nt) {
if (bc->channel <=0 ) { /* else we have the channel already */
- bc->channel = find_free_chan_in_stack(stack, 0);
+ bc->channel = find_free_chan_in_stack(stack, bc, 0);
if (!bc->channel) {
cb_log(-1, stack->port, " No free channel at the moment\n");
Modified: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?rev=30132&r1=30131&r2=30132&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Wed May 24 18:21:03 2006
@@ -100,6 +100,7 @@
EVENT_DTMF_TONE,
EVENT_NEW_L3ID,
EVENT_NEW_BC,
+ EVENT_NEW_CHANNEL,
EVENT_UNKNOWN
};
Modified: trunk/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_msg_parser.c?rev=30132&r1=30131&r2=30132&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_msg_parser.c (original)
+++ trunk/channels/misdn/isdn_msg_parser.c Wed May 24 18:21:03 2006
@@ -39,11 +39,14 @@
cb_log(0,bc->port,"We already have a channel (%d)\n", bc->channel);
} else {
bc->channel = channel;
+ cb_event(EVENT_NEW_CHANNEL,bc,NULL);
}
}
- if (channel > 0 && !bc->nt )
+ if (channel > 0 && !bc->nt ) {
bc->channel = channel;
+ cb_event(EVENT_NEW_CHANNEL,bc,NULL);
+ }
}
void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt)
@@ -1206,6 +1209,7 @@
char EVENT_DTMF_TONE_INFO[] = "DTMF_TONE";
char EVENT_NEW_L3ID_INFO[] = "NEW_L3ID";
char EVENT_NEW_BC_INFO[] = "NEW_BC";
+char EVENT_NEW_CHANNEL_INFO[] = "NEW_CHANNEL";
char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA";
char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED";
char EVENT_TONE_GENERATE_INFO[] = "TONE_GENERATE";
@@ -1220,6 +1224,7 @@
if (event == EVENT_DTMF_TONE) return EVENT_DTMF_TONE_INFO;
if (event == EVENT_NEW_L3ID) return EVENT_NEW_L3ID_INFO;
if (event == EVENT_NEW_BC) return EVENT_NEW_BC_INFO;
+ if (event == EVENT_NEW_CHANNEL) return EVENT_NEW_CHANNEL_INFO;
if (event == EVENT_BCHAN_DATA) return EVENT_BCHAN_DATA_INFO;
if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO;
if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO;
More information about the asterisk-commits
mailing list