From 6d4776e178415e8d91691553c2028f2c6d8a9329 Mon Sep 17 00:00:00 2001 From: leecher1337 Date: Mon, 13 Jan 2025 12:33:52 +0100 Subject: [PATCH] [Core] Add handling of sendrcv flag for RFC4103 Real-Time Text (RTT). Fix bug that always used RTP RED, even when not advertised by peer leading to garbled text. --- src/switch_core_media.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index de5d0eff74..9bf83aab1f 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -3234,7 +3234,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session if (type == SWITCH_MEDIA_TYPE_TEXT && !switch_test_flag((&engine->read_frame), SFF_CNG)) { - if (engine->red_pt) { + if (engine->red_pt == engine->read_frame.payload) { unsigned char *p = engine->read_frame.data; *(p + engine->read_frame.datalen) = '\0'; @@ -5892,6 +5892,25 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s got_text++; + switch_core_media_set_rmode(smh->session, SWITCH_MEDIA_TYPE_TEXT, sdp_media_flow(m->m_mode), sdp_type); + + if (sdp_type == SDP_TYPE_REQUEST) { + switch(t_engine->rmode) { + case SWITCH_MEDIA_FLOW_RECVONLY: + switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_TEXT, SWITCH_MEDIA_FLOW_SENDONLY, sdp_type); + break; + case SWITCH_MEDIA_FLOW_SENDONLY: + switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_TEXT, SWITCH_MEDIA_FLOW_RECVONLY, sdp_type); + break; + case SWITCH_MEDIA_FLOW_INACTIVE: + switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_TEXT, SWITCH_MEDIA_FLOW_INACTIVE, sdp_type); + break; + default: + switch_core_media_set_smode(smh->session, SWITCH_MEDIA_TYPE_TEXT, SWITCH_MEDIA_FLOW_SENDRECV, sdp_type); + break; + } + } + for (map = m->m_rtpmaps; map; map = map->rm_next) { payload_map_t *pmap;