Hello all!
I’m using asterisk and want to make sip calls from addpac gateway (FXS) to ekiga softphone.
I have the following entries in sip.conf file:
[size=75][code]
" Addpac
[210]
username=210
secret=xxxxx
qualify=yes
canreinvite=no
disallow=all
allow=g729,alaw,ulaw
type=friend
host=xxxxx
context=incoming_call
" ekiga
[255]
username=255
qualify=yes
canreinvite=yes
type=friend
disallow=all
allow=gsm,ulaw,alaw
host=dynamic
context=incoming_call[/code][/size]
When I call 255 from 210 I get the error:
From sip debug 3 I get:
[quote][Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:2702 do_setnat: Setting NAT on RTP to Off
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:5346 process_sdp: T38 state changed to 0 on channel
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:5426 process_sdp: We’re settling with these formats: 0x10c (ulaw|alaw|g729)
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:13748 handle_request_invite: Checking SIP call limits for device 210
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:3140 update_call_counter: Updating call counter for incoming call
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:3977 sip_new: *** Our native formats are 0x100 (g729)
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:3978 sip_new: *** Joint capabilities are 0x10c (ulaw|alaw|g729)
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:3979 sip_new: *** Our capabilities are 0x10c (ulaw|alaw|g729)
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:3980 sip_new: *** AST_CODEC_CHOOSE formats are 0x100 (g729)
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:4003 sip_new: This channel will not be able to handle video.
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:8203 build_route: build_route: Contact hop: sip:210@10.128.96.56
[Dec 4 17:16:14] DEBUG[13123]: chan_sip.c:13827 handle_request_invite: SIP/210-081c0ae8: New call is still down… Trying…
[Dec 4 17:16:14] DEBUG[13123]: devicestate.c:304 __ast_device_state_changed_literal: Notification of state change to be queued on device/channel SIP/210-081c0ae8
[Dec 4 17:16:14] DEBUG[13140]: pbx.c:1814 pbx_extension_helper: Launching ‘Dial’
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:15764 sip_request_call: Asked to create a SIP channel with formats: 0x100 (g729)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:4488 sip_alloc: Allocating new SIP dialog for (No Call-ID) - INVITE (With RTP)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:2702 do_setnat: Setting NAT on RTP to Off
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:3977 sip_new: *** Our native formats are 0x2 (gsm)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:3978 sip_new: *** Joint capabilities are 0x0 (nothing)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:3979 sip_new: *** Our capabilities are 0xe (gsm|ulaw|alaw)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:3980 sip_new: *** AST_CODEC_CHOOSE formats are 0x2 (gsm)
[Dec 4 17:16:14] DEBUG[13140]: chan_sip.c:3982 sip_new: *** Our preferred formats from the incoming channel are 0x100 (g729) [/quote]
I think the problem is in jointcapability that first peer declares. My idea was to set jointcapability of first peer compatible to second’s peer capabilities.
I wrote I simple (and may be buggy) patch to chan_sip.c:
[code]*************** static struct ast_channel *sip_new(struc
*** 3937,3962 ****
else
tmp->tech = &sip_tech;
-
/*
-
if extension number is not empty get list of allowed codecs
-
and set up jointcapability
-
*/
-
if (strlen(i->exten)) {
-
int mask = 0;
-
char cCodec[BUFSIZ];
-
struct ast_config *cfg = ast_config_load(config);
-
strcpy(cCodec, ast_config_option(cfg, i->exten, "allow"));
-
ast_log(LOG_NOTICE, "+++ Allowed codec list (text mode) for user %s = %s\n", i->exten, cCodec);
-
ast_parse_allow_disallow(NULL, &mask, cCodec, 1);
-
ast_log(LOG_NOTICE, "+++ Allowed codec list (binary mode) for user %s = 0x%X\n", i->exten, mask);
-
i->jointcapability &= mask;
-
free(cfg);
-
}
-
/* Select our native format based on codec preference until we receive something from another device to the contrary. */ if (i->jointcapability) { /* The joint capabilities of us and peer */
— 3937,3942 ----
[/code]
Now first peer declares alaw&ulaw as the only common codecs within 210 and 255.
[quote][Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:2702 do_setnat: Setting NAT on RTP to Off
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:5346 process_sdp: T38 state changed to 0 on channel
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:5426 process_sdp: We’re settling with these formats: 0x10c (ulaw|alaw|g729)
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:13748 handle_request_invite: Checking SIP call limits for device 210
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:3140 update_call_counter: Updating call counter for incoming call
[Dec 4 17:30:42] DEBUG[15262]: config.c:880 config_text_file_load: Parsing /etc/asterisk/sip.conf
[Dec 4 17:30:42] NOTICE[15262]: chan_sip.c:3951 sip_new: +++ Allowed codec list (text mode) for user 255 = gsm,ulaw,alaw
[Dec 4 17:30:42] NOTICE[15262]: chan_sip.c:3953 sip_new: +++ Allowed codec list (binary mode) for user 255 = 0xE
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:3977 sip_new: *** Our native formats are 0x8 (alaw)
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:3978 sip_new: *** Joint capabilities are 0xc (ulaw|alaw)
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:3979 sip_new: *** Our capabilities are 0x10c (ulaw|alaw|g729)
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:3980 sip_new: *** AST_CODEC_CHOOSE formats are 0x8 (alaw)
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:4003 sip_new: This channel will not be able to handle video.
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:8203 build_route: build_route: Contact hop: sip:210@10.128.96.56
[Dec 4 17:30:42] DEBUG[15262]: chan_sip.c:13827 handle_request_invite: SIP/210-081c0980: New call is still down… Trying…
[Dec 4 17:30:42] DEBUG[15262]: devicestate.c:304 __ast_device_state_changed_literal: Notification of state change to be queued on device/channel SIP/210-081c0980
[Dec 4 17:30:42] DEBUG[15256]: chan_sip.c:15695 sip_devicestate: Checking device state for peer 210
[Dec 4 17:30:42] DEBUG[15256]: devicestate.c:287 do_state_change: Changing state for SIP/210 - state 1 (Not in use)
[Dec 4 17:30:42] DEBUG[15278]: pbx.c:1814 pbx_extension_helper: Launching ‘Dial’
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:15764 sip_request_call: Asked to create a SIP channel with formats: 0x8 (alaw)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:4488 sip_alloc: Allocating new SIP dialog for (No Call-ID) - INVITE (With RTP)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:2702 do_setnat: Setting NAT on RTP to Off
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:3977 sip_new: *** Our native formats are 0x2 (gsm)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:3978 sip_new: *** Joint capabilities are 0x0 (nothing)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:3979 sip_new: *** Our capabilities are 0xe (gsm|ulaw|alaw)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:3980 sip_new: *** AST_CODEC_CHOOSE formats are 0x2 (gsm)
[Dec 4 17:30:42] DEBUG[15278]: chan_sip.c:3982 sip_new: *** Our preferred formats from the incoming channel are 0x8 (alaw) [/quote]
…and everything works.
sip show channels:
[quote]*CLI> sip show channels
Peer User/ANR Call ID Seq (Tx/Rx) Form Hold Last Message
192.168.100.1 255 2be037bb1b3 00102/00000 alaw No Tx: ACK
10.128.96.56 210 a9287843-90 00101/01077 alaw No Rx: ACK
2 active SIP channels
[/quote]
But maybe anyone knows how to choose a common codec within extensions using native ways? Thanks.