From acd052f6e9516645f58146863cc0c1bf1f6b64c3 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 22 Jun 2024 13:28:23 -0600 Subject: [PATCH] Updated patches for FreeSWITCH --- debian/resources/switch/source-release.sh | 9 +- debian/resources/switch/source/pull_2300.diff | 169 ++++++++++++++++++ .../switch/source/rtp_timestamp.patch | 10 -- .../resources/switch/source/switch_rtp.diff | 12 ++ 4 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 debian/resources/switch/source/pull_2300.diff delete mode 100644 debian/resources/switch/source/rtp_timestamp.patch create mode 100644 debian/resources/switch/source/switch_rtp.diff diff --git a/debian/resources/switch/source-release.sh b/debian/resources/switch/source-release.sh index d24af3b..e979563 100755 --- a/debian/resources/switch/source-release.sh +++ b/debian/resources/switch/source-release.sh @@ -105,9 +105,12 @@ if [ $switch_branch = "stable" ]; then mv freeswitch-$switch_version.-release freeswitch-$switch_version cd /usr/src/freeswitch-$switch_version - #apply rtp timestamp patch - Fix RTP audio issues use the following for additional information. https://github.com/briteback/freeswitch/commit/9f8968ccabb8a4e0353016d4ea0ff99561b005f1 - patch -u /usr/src/freeswitch-$switch_version/src/switch_rtp.c -i /usr/src/fusionpbx-install.sh/debian/resources/switch/source/rtp_timestamp.patch - + #apply rtp timestamp patch - Fix RTP audio issues use the following for additional information. https://github.com/briteback/freeswitch/commit/9f8968ccabb8a4e0353016d4ea0ff99561b005f1 + patch -u /usr/src/freeswitch-$switch_version/src/switch_rtp.c -i /usr/src/fusionpbx-install.sh/debian/resources/switch/source/switch_rtp.diff + + #apply pull request 2300 to Fix session deadlock that results in stale or stuck calls. https://github.com/signalwire/freeswitch/pull/2300 + patch -d /usr/src/freeswitch-$switch_version/src -i /usr/src/fusionpbx-install.sh/debian/resources/switch/source/pull_2300.diff + #apply mod_pgsql patch #patch -u /usr/src/freeswitch-$switch_version/src/mod/databases/mod_pgsql/mod_pgsql.c -i /usr/src/fusionpbx-install.sh/debian/resources/switch/source/mod_pgsql.patch fi diff --git a/debian/resources/switch/source/pull_2300.diff b/debian/resources/switch/source/pull_2300.diff new file mode 100644 index 0000000..ba25544 --- /dev/null +++ b/debian/resources/switch/source/pull_2300.diff @@ -0,0 +1,169 @@ +diff --git a/src/switch_core_io.c b/src/switch_core_io.c +index 9931f0f3ef7..ee968b63dd9 100644 +--- a/src/switch_core_io.c ++++ b/src/switch_core_io.c +@@ -146,13 +146,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi + if (session->read_codec && !session->track_id && session->track_duration) { + if (session->read_frame_count == 0) { + switch_event_t *event; +- switch_core_session_message_t msg = { 0 }; ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); + + session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * session->track_duration; + +- msg.message_id = SWITCH_MESSAGE_HEARTBEAT_EVENT; +- msg.numeric_arg = session->track_duration; +- switch_core_session_receive_message(session, &msg); ++ msg->message_id = SWITCH_MESSAGE_HEARTBEAT_EVENT; ++ msg->numeric_arg = session->track_duration; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); ++ + + switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT); + switch_channel_event_set_data(session->channel, event); +@@ -410,10 +412,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi + switch_set_flag(session, SSF_READ_TRANSCODE); + + if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) { +- switch_core_session_message_t msg = { 0 }; +- +- msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); + switch_set_flag(session, SSF_WARN_TRANSCODE); + } + +@@ -562,10 +564,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi + status = SWITCH_STATUS_FALSE; + goto done; + } else { +- switch_core_session_message_t msg = { 0 }; +- msg.numeric_arg = 1; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 1; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Activating read resampler\n"); + } +@@ -597,10 +600,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi + switch_mutex_unlock(session->resample_mutex); + + { +- switch_core_session_message_t msg = { 0 }; +- msg.numeric_arg = 0; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 0; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); ++ + } + + } +diff --git a/src/switch_core_media.c b/src/switch_core_media.c +index 4b6d8aff8b6..e09242ee0d5 100644 +--- a/src/switch_core_media.c ++++ b/src/switch_core_media.c +@@ -15945,12 +15945,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + } + + if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) { +- switch_core_session_message_t msg = { 0 }; +- +- msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); + switch_set_flag(session, SSF_WARN_TRANSCODE); +- } ++ } + + if (frame->codec) { + session->raw_write_frame.datalen = session->raw_write_frame.buflen; +@@ -15993,10 +15993,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + if (status != SWITCH_STATUS_SUCCESS) { + goto done; + } else { +- switch_core_session_message_t msg = { 0 }; +- msg.numeric_arg = 1; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 1; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); ++ + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Activating write resampler\n"); + } +@@ -16029,10 +16031,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + switch_mutex_unlock(session->resample_mutex); + + { +- switch_core_session_message_t msg = { 0 }; +- msg.numeric_arg = 0; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 0; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); + } + + } +@@ -16329,11 +16332,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + if (status != SWITCH_STATUS_SUCCESS) { + goto done; + } else { +- switch_core_session_message_t msg = { 0 }; +- msg.numeric_arg = 1; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); +- ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 1; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Activating write resampler\n"); + } +@@ -16351,7 +16354,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + break; + case SWITCH_STATUS_NOOP: + if (session->write_resampler) { +- switch_core_session_message_t msg = { 0 }; ++ + int ok = 0; + + switch_mutex_lock(session->resample_mutex); +@@ -16363,9 +16366,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess + switch_mutex_unlock(session->resample_mutex); + + if (ok) { +- msg.numeric_arg = 0; +- msg.message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; +- switch_core_session_receive_message(session, &msg); ++ switch_core_session_message_t *msg = switch_core_session_alloc(session, sizeof(*msg)); ++ msg->message_id = SWITCH_MESSAGE_RESAMPLE_EVENT; ++ msg->numeric_arg = 0; ++ MESSAGE_STAMP_FFL(msg); ++ switch_core_session_queue_message(session, msg); ++ + } + + } diff --git a/debian/resources/switch/source/rtp_timestamp.patch b/debian/resources/switch/source/rtp_timestamp.patch deleted file mode 100644 index 441f886..0000000 --- a/debian/resources/switch/source/rtp_timestamp.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- switch_rtp.c 2024-06-22 15:48:16.879125840 +0000 -+++ switch_rtp.c 2024-06-22 15:50:05.055559774 +0000 -@@ -8904,6 +8904,7 @@ - data = frame->data; - len = frame->datalen; - ts = rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] ? (uint32_t) frame->timestamp : 0; -+ if (!ts) ts = rtp_session->last_write_ts + rtp_session->samples_per_interval; - } - - /* diff --git a/debian/resources/switch/source/switch_rtp.diff b/debian/resources/switch/source/switch_rtp.diff new file mode 100644 index 0000000..828360a --- /dev/null +++ b/debian/resources/switch/source/switch_rtp.diff @@ -0,0 +1,12 @@ +diff --git a/src/switch_rtp.c b/src/switch_rtp.c +index 1125e2f59bc..7ff161383aa 100644 +--- a/src/switch_rtp.c ++++ b/src/switch_rtp.c +@@ -8904,6 +8904,7 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra + data = frame->data; + len = frame->datalen; + ts = rtp_session->flags[SWITCH_RTP_FLAG_RAW_WRITE] ? (uint32_t) frame->timestamp : 0; ++ if (!ts) ts = rtp_session->last_write_ts + rtp_session->samples_per_interval; + } + + /* \ No newline at end of file