From 032032df65e6f2b3152e9c1d54e247a4af22e793 Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Mon, 29 Sep 2025 15:42:23 -0300 Subject: [PATCH 1/2] Only remove ESP32 ICE candidates if host is defined. --- src/pipecat/runner/utils.py | 7 +++++-- src/pipecat/transports/smallwebrtc/request_handler.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pipecat/runner/utils.py b/src/pipecat/runner/utils.py index c505fdaa6..530854050 100644 --- a/src/pipecat/runner/utils.py +++ b/src/pipecat/runner/utils.py @@ -301,6 +301,7 @@ def _smallwebrtc_sdp_cleanup_ice_candidates(text: str, pattern: str) -> str: Returns: Cleaned SDP text with filtered ICE candidates. """ + logger.debug("Removing unsupported ICE candidates from SDP") result = [] lines = text.splitlines() for line in lines: @@ -321,6 +322,7 @@ def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str: Returns: SDP text with sha-384 and sha-512 fingerprints removed. """ + logger.debug("Removing unsupported fingerprints from SDP") result = [] lines = text.splitlines() for line in lines: @@ -329,7 +331,7 @@ def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str: return "\r\n".join(result) -def smallwebrtc_sdp_munging(sdp: str, host: str) -> str: +def smallwebrtc_sdp_munging(sdp: str, host: Optional[str]) -> str: """Apply SDP modifications for SmallWebRTC compatibility. Args: @@ -340,7 +342,8 @@ def smallwebrtc_sdp_munging(sdp: str, host: str) -> str: Modified SDP string with fingerprint and ICE candidate cleanup. """ sdp = _smallwebrtc_sdp_cleanup_fingerprints(sdp) - sdp = _smallwebrtc_sdp_cleanup_ice_candidates(sdp, host) + if host: + sdp = _smallwebrtc_sdp_cleanup_ice_candidates(sdp, host) return sdp diff --git a/src/pipecat/transports/smallwebrtc/request_handler.py b/src/pipecat/transports/smallwebrtc/request_handler.py index a4e6b43a2..3a6c77843 100644 --- a/src/pipecat/transports/smallwebrtc/request_handler.py +++ b/src/pipecat/transports/smallwebrtc/request_handler.py @@ -180,7 +180,7 @@ class SmallWebRTCRequestHandler: answer = pipecat_connection.get_answer() - if self._esp32_mode and self._host and self._host != "localhost": + if self._esp32_mode: from pipecat.runner.utils import smallwebrtc_sdp_munging answer["sdp"] = smallwebrtc_sdp_munging(answer["sdp"], self._host) From fb160646b8af3815751010cdaee3277213970875 Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Wed, 1 Oct 2025 14:18:39 -0300 Subject: [PATCH 2/2] Fixing the SDP munging to keep it working on Chrome. --- src/pipecat/runner/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pipecat/runner/utils.py b/src/pipecat/runner/utils.py index 530854050..3466e9a6d 100644 --- a/src/pipecat/runner/utils.py +++ b/src/pipecat/runner/utils.py @@ -310,7 +310,7 @@ def _smallwebrtc_sdp_cleanup_ice_candidates(text: str, pattern: str) -> str: result.append(line) else: result.append(line) - return "\r\n".join(result) + return "\r\n".join(result) + "\r\n" def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str: @@ -328,7 +328,7 @@ def _smallwebrtc_sdp_cleanup_fingerprints(text: str) -> str: for line in lines: if not re.search("sha-384", line) and not re.search("sha-512", line): result.append(line) - return "\r\n".join(result) + return "\r\n".join(result) + "\r\n" def smallwebrtc_sdp_munging(sdp: str, host: Optional[str]) -> str: