freeswitch-stable: add T.38 reINVITE fix
[feed/telephony.git] / net / freeswitch-stable / patches / 390-t38-reinvite-488-fix.patch
1 commit 167294ea2649afd0ffedf4520b0f308979c3ca2a
2 Author: Sebastian Kemper <sebastian_ml@gmx.net>
3 Date: Fri Oct 18 18:28:07 2019 +0200
4
5 [mod-sofia] Fix reINVITE after T38 is rejected
6
7 From FS-11833.
8
9 After FS sends a reINVITE to T38 which gets rejected by peer it is no
10 longer in a state where it can properly answer a reINVITE which requests
11 a change of the media setup.
12
13 1. FS sends INVITE (destination is a fax machine)
14 2. Call connects with "8 101"
15 3. FS sends reINVITE to T38
16 4. T38 rejected (488)
17 5. FS receives INVITE to "8"
18 6. FS replies with 200 OK without SDP
19 7. Call fails
20
21 The bug is related to TFLAG_SDP. This flag is set when a media session
22 is established. And when there's a reINVITE sofia_glue_do_invite() from
23 sofia_glue.c is called and clears the flag again:
24
25 sofia_clear_flag_locked(tech_pvt, TFLAG_SDP);
26
27 So when FS sends a reINVITE to T38 the flag gets cleared. But when the
28 reINVITE is rejected with 488 the flag is not set again. It stays
29 cleared. So the call continues with the previously negotiated media, fax
30 passthrough (8 101 in this case), but TFLAG_SDP is not set.
31
32 So when FS receives a reINVITE at this point it doesn't see the need to
33 renegotiate anything, even though it realizes that 2833 DTMF is now off:
34
35 2019-04-30 16:42:12.478025 [DEBUG] switch_core_media.c:5478 Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMA:8:8000:20:64000:1]
36 2019-04-30 16:42:12.478025 [DEBUG] switch_core_media.c:5533 Audio Codec Compare [PCMA:8:8000:20:64000:1] ++++ is saved as a match
37 2019-04-30 16:42:12.478025 [DEBUG] switch_core_media.c:5802 No 2833 in SDP. Disable 2833 dtmf and switch to INFO
38
39 When FS doesn't send a reINVITE (fax_enable_t38_request=false) and the
40 reINVITE to "8" is received, TFLAG_SDP is still set and then FS
41 understands that it needs to renegotiate and replies with a 200 OK that
42 includes SDP:
43
44 2019-04-30 16:41:19.358028 [DEBUG] switch_core_media.c:5478 Audio Codec Compare [PCMA:8:8000:20:64000:1]/[PCMA:8:8000:20:64000:1]
45 2019-04-30 16:41:19.358028 [DEBUG] switch_core_media.c:5533 Audio Codec Compare [PCMA:8:8000:20:64000:1] ++++ is saved as a match
46 2019-04-30 16:41:19.358028 [DEBUG] switch_core_media.c:5802 No 2833 in SDP. Disable 2833 dtmf and switch to INFO
47 2019-04-30 16:41:19.358028 [DEBUG] sofia.c:8237 skemper was here in line 8232
48 2019-04-30 16:41:19.358028 [DEBUG] switch_core_media.c:8390 skemper was here in line 8390.
49 2019-04-30 16:41:19.358028 [DEBUG] switch_core_media.c:8496 Audio params are unchanged for sofia/external/+called_number.
50 2019-04-30 16:41:19.358028 [DEBUG] sofia.c:8243 Processing updated SDP
51
52 This fixes the state problem after a rejected T38 reINVITE by setting
53 TFLAG_SDP.
54
55 Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
56
57 --- a/src/mod/endpoints/mod_sofia/sofia.c
58 +++ b/src/mod/endpoints/mod_sofia/sofia.c
59 @@ -6501,6 +6501,7 @@ static void sofia_handle_sip_r_invite(sw
60 switch_channel_clear_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_REQ);
61 switch_channel_set_app_flag_key("T38", tech_pvt->channel, CF_APP_T38_FAIL);
62 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s T38 invite failed\n", switch_channel_get_name(tech_pvt->channel));
63 + sofia_set_flag(tech_pvt, TFLAG_SDP);
64 }
65
66