[asterisk-commits] branch crichter/0.4.0 r30130 - in
/team/crichter/0.4.0/channels: ./ misdn/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed May 24 16:01:35 MST 2006
Author: crichter
Date: Wed May 24 18:01:35 2006
New Revision: 30130
URL: http://svn.digium.com/view/asterisk?rev=30130&view=rev
Log:
added EVENT_NEW_CHANNEL. We change the channel name now when we got the real channel
Modified:
team/crichter/0.4.0/channels/chan_misdn.c
team/crichter/0.4.0/channels/misdn/isdn_lib.c
team/crichter/0.4.0/channels/misdn/isdn_lib.h
team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=30130&r1=30129&r2=30130&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Wed May 24 18:01:35 2006
@@ -2535,25 +2535,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++;
snprintf(tmp->name, sizeof(tmp->name), "%s/%d-u%d",
misdn_type, port, c);
- } else {
+ } else {
snprintf(tmp->name, sizeof(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->type = misdn_type;
tmp->nativeformats = prefformat;
@@ -3093,10 +3100,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;
@@ -3415,6 +3425,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: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=30130&r1=30129&r2=30130&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Wed May 24 18:01:35 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) */
@@ -1399,7 +1401,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;
@@ -2880,7 +2882,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: team/crichter/0.4.0/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.h?rev=30130&r1=30129&r2=30130&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.h (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.h Wed May 24 18:01:35 2006
@@ -100,6 +100,7 @@
EVENT_DTMF_TONE,
EVENT_NEW_L3ID,
EVENT_NEW_BC,
+ EVENT_NEW_CHANNEL,
EVENT_UNKNOWN
};
Modified: team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c?rev=30130&r1=30129&r2=30130&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_msg_parser.c Wed May 24 18:01:35 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