Hi everyone!
In my environment I use FreeSwitch as media server and session border
controller. SIP routing is mostly done with my private B2BUA. The problem
itself is in my "hold" functionality. In details: A is calling to B:
<!--
if the calling party is the called party, go to their VM
if the calling party is NOT the called party dial the extension
(1000-1019) for 30 seconds and go to voicemail if the
call fails (continue_on_fail=true), otherwise hang up after a
successful bridge (hangup_after-bridge=true)
-->
<extension name="Local_Extension_from_SP">
<condition field="${sip_contact_uri}"
expression="^.*StarPound_.*_B2BUA.*$"/>
<condition field="destination_number" expression="^([0-9]{2,9})$">
<action application="set" data="dialed_extension=$1"/>
<action application="export" data="dialed_extension=$1"/>
</condition>
<condition field="${sip_to_host}" expression="^([^.]*)\..*$">
<action application="set" data="orgname=$1"/>
</condition>
<condition field="destination_number" expression="^${caller_id_number}$">
<anti-action application="set" data="ringback=${us-ring}"/>
<anti-action application="set" data="transfer_ringback=${us-ring}"/>
<anti-action application="set" data="call_timeout=10"/>
<anti-action application="set" data="hangup_after_bridge=true"/>
<anti-action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION,USER_NOT_REGISTERED"/>
<anti-action application="set" data="continue_on_fail=true"/>
<anti-action application="db" data="insert/${domain_name}-call_return/${dialed_extension}/${caller_id_number}"/>
<anti-action application="db" data="insert/${domain_name}-last_dial_ext/${dialed_extension}/${uuid}"/>
<anti-action application="set" data="called_party_callgroup=${user_data(${dialed_extension}@${domain_name}var callgroup)}"/>
<anti-action application="db" data="insert/${domain_name}-last_dial/${called_party_callgroup}/${uuid}"/>
<anti-action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
<anti-action application="answer"/>
<anti-action application="export" data="sip_h_X-SPFrom="e;${sip_from_user}"e;<${sip_from_uri}>"/>
<anti-action application="export" data="sip_h_X-SPTo=<${sip_to_uri}>"/>
<anti-action application="export" data="sip_h_X-SPCallId=${sip_call_id}"/>
<anti-action application="bridge" data="sofia/external/${orgname}send2voicemail@$${starpound_sip_app_server}"/>
</condition>
</extension>
Call being answered. Then B wants to hold a call (A should hear music-on-hold, B should hear nothing but still have a call). To accomplish this I:
1. on behalf of B2BUA make call to FreeSwitch "hold" extension, get SDP for music-on-hold (moh_sdp)
<extension name="hold">
<condition field="destination_number" expression="hold">
<action application="answer"/>
<action application="playback" data="$${hold_music}"/>
</condition>
</extension>
2. re-invite A with SDP moh_sdp
3. re-invite B with it's own sdp and attribute 'inactive' (also tried re-invite with A's SDP and 'inactive' and with 0.0.0.0 IP in SDP and 'inactive' - same results)
Result: both A and B hear music-on-hold.
I suspect that the reason is in 'bridge' function.. it seems, that it still bridges media against the SIP.
Here is a snippet from FreeSwitch log related to "strange" (from my point of view) behaviour - when FreeSwitch change media for B to the incorrect one.
Here 1004 is B.
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2939 sofia_glue_negotiate_sdp()
Audio Codec Compare [GSM:3:8000:20]/[GSM:3:8000:20]
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:1863 sofia_glue_tech_set_codec()
Already using GSM
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2899 sofia_glue_negotiate_sdp()
Set 2833 dtmf payload to 101
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2908 sofia_glue_negotiate_sdp()
Set comfort noise payload to 13
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2139 sofia_glue_activate_rtp()
Audio params changed for sofia/external/6782886802@10.249.194.9:5060 from
75.101.166.29:27426 to 75.101.166.29:22922
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2146 sofia_glue_activate_rtp()
AUDIO RTP [sofia/external/6782886802@10.249.194.9:5060] 10.249.194.9 port
28594 -> 75.101.166.29 port 22922 codec: 3 ms: 20
2009-05-26 13:19:14 [DEBUG] sofia_glue.c:2165 sofia_glue_activate_rtp()
AUDIO RTP CHANGING DEST TO: [75.101.166.29:22922]
2009-05-26 13:19:14 [DEBUG] sofia.c:2996 sofia_handle_sip_i_state()
Channel sofia/external/1005@10.249.194.9 entering state [ready][200]
2009-05-26 13:19:15 [DEBUG] switch_ivr.c:540 switch_ivr_parse_event()
sofia/doublenat5090/sip:1004@172.16.0.6;fs_nat=yes;fs_path=sip%3A1004%40193.33.170.63%3A5060
Command Execute playback(local_stream://moh)
EXECUTE sofia/doublenat5090/sip:1004@172.16.0.6;fs_nat=yes;fs_path=sip%3A1004%40193.33.170.63%3A5060 playback(local_stream://moh)
2009-05-26 13:19:15 [DEBUG] mod_local_stream.c:346
local_stream_file_open() Opening Stream [moh/8000] 8000hz
2009-05-26 13:19:15 [DEBUG] switch_ivr_play_say.c:1084
switch_ivr_play_file() Codec Activated L16@8000hz 1 channels 20ms
2009-05-26 13:19:15 [DEBUG] switch_core_io.c:649
switch_core_session_write_frame()
sofia/doublenat5090/sip:1004@172.16.0.6;fs_nat=yes;fs_path=sip%3A1004%40193.33.170.63%3A5060
receive message [TRANSCODING_NECESSARY]
Any thoughts would be really appreciated!
Artem